Skip to content

Type checker crash on a non-returning for ... into: expression #15747

Description

@AlexGx

Existing issue

  • I have searched existing issues and could not find a duplicate.

Elixir and Erlang/OTP versions

Erlang/OTP 29 [erts-17.0.5] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit] [dtrace]

Elixir 1.21.0-dev (bc7844c) (compiled with Erlang/OTP 29)

Operating system

any

Current behavior

Compiling this code crashes

defmodule CrashRepro do
  def foo(list) do
    for x <- list, into: raise("oops"), do: x
  end
end

with

** (RuntimeError) found error while checking types for CrashRepro.foo/1:

** (CaseClauseError) no case clause matching:

    {false, false}

The exception happened while checking this code:

def foo(list) do
  for x <- list,
      do: x,
      into: :erlang.error(RuntimeError.exception("oops"), :none, error_info: %{module: Exception})
end

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

    (elixir 1.21.0-dev) lib/module/types/expr.ex:861: Module.Types.Expr.for_into/4
    (elixir 1.21.0-dev) lib/module/types/expr.ex:624: anonymous fn/6 in Module.Types.Expr.of_expr/5
    (elixir 1.21.0-dev) lib/module/types.ex:410: anonymous fn/7 in Module.Types.infer_local_handler/7
    (elixir 1.21.0-dev) lib/enum.ex:2623: Enum."-reduce/3-lists^foldl/2-0-"/3
    (elixir 1.21.0-dev) lib/module/types.ex:398: Module.Types.infer_local_handler/7
    (elixir 1.21.0-dev) lib/module/types.ex:302: Module.Types.local_handler/5
    (elixir 1.21.0-dev) lib/module/types.ex:86: anonymous fn/5 in Module.Types.infer/7

Expected behavior

No crash / produce diagnostic ?

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