Skip to content

Inconsistent error while checking types #15156

@IvanIvanoff

Description

@IvanIvanoff

Elixir and Erlang/OTP versions

Erlang/OTP 27 [erts-15.2.7.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]
Interactive Elixir (1.20.0-rc.2) - press Ctrl+C to exit (type h() ENTER for help)

(latest main branch 92e1830)

Operating system

MacOS 15.7.3

Current behavior

The error I get contains Please report this bug at: https://github.com/elixir-lang/elixir/issues.

Reproducing repo: https://github.com/IvanIvanoff/clickhousex_error

To reproduce the error:

# sometimes if I don't run deps.clean compilation succeeds, especially if I change Elixir/OTP version
mix deps.clean clickhosuex
mix deps.clean clickhouse_ecto
mix deps.get
mix compile

The error is fixed by applying this change: https://github.com/santiment/clickhousex/pull/13/changes
(These ClickHouse dependencies are not maintained for years, I'm switching to Plausible Analytics ones)

== Compilation error in file lib/clickhousex/error.ex ==
** (RuntimeError) found error while checking types for Clickhousex.Error.exception/1:

** (MatchError) no match of right hand side value:

    %{
      vars: %{},
      warnings: [],
      failed: false,
      local_sigs: %{
        {:__struct__, 0} => {:def,
         {:infer, nil,
          [
            {[],
             %{
               map: {:closed,
                [
                  __exception__: %{atom: {:union, %{true: []}}},
                  __struct__: %{atom: {:union, %{Clickhousex.Error => []}}},
                  code: %{bitmap: 8},
                  constraint_violations: %{bitmap: 4},
                  message: %{bitmap: 1}
                ]}
             }}
          ]}, [{0, 0}]},
        {:__struct__, 1} => {:def,
         {:infer, nil,
          [
            {[
               %{
                 atom: {:negation, %{}},
                 list: {:term, :term},
                 map: {{:closed,
                   [
                     __struct__: %{atom: {:union, %{Range => []}}},
                     first: :term,
                     last: :term,
                     step: :term
                   ]}, :bdd_top, :bdd_bot,
                  {{:open, []}, :bdd_top,
                   {:open, [__struct__: %{atom: {:negation, %{}}}]}, :bdd_bot}},
                 fun: {:negation, %{}},
                 tuple: {:open, []},
                 bitmap: 255
               }
             ], %{dynamic: :term}}
          ]}, [{0, 0}]},
        {:exception, 1} => :def
      },
      local_used: %{},
      conditional_vars: nil,
      ...
    }

The exception happened while checking this code:

def exception(%Mint.TransportError{reason: reason}) do
  %Clickhousex.Error{
    __exception__: true,
    code: 0,
    constraint_violations: [],
    message: <<"Transport Error: ", Kernel.inspect(reason)::binary>>
  }
end

Please report this bug at: https://github.com/elixir-lang/elixir/issues

    (elixir 1.20.0-rc.2) lib/module/types/of.ex:98: Module.Types.Of.refine_body_var/5
    (elixir 1.20.0-rc.2) lib/module/types/expr.ex:527: Module.Types.Expr.of_expr/5
    (elixir 1.20.0-rc.2) lib/module/types/helpers.ex:562: Module.Types.Helpers.zip_map_reduce/5
    (elixir 1.20.0-rc.2) lib/module/types/apply.ex:356: Module.Types.Apply.remote/8
    (elixir 1.20.0-rc.2) lib/module/types/of.ex:613: Module.Types.Of.bitstring_segment/5
    (elixir 1.20.0-rc.2) lib/module/types/of.ex:564: Module.Types.Of.bitstring_tail/5
    (elixir 1.20.0-rc.2) lib/module/types/expr.ex:127: Module.Types.Expr.of_expr/5
    (elixir 1.20.0-rc.2) lib/module/types/of.ex:485: anonymous fn/5 in Module.Types.Of.struct_instance/7

Expected behavior

No error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions