-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
Elixir and Erlang/OTP versions
Erlang/OTP 26 [erts-14.2.5.2] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [jit]
Elixir 1.18.0-dev (f2f4f3a) (compiled with Erlang/OTP 26)
Operating system
any
Current behavior
This works
try do; :ok; catch; a, b, c -> :ok; end
error: expected one or two args for :catch clauses (->) in "try"
└─ iex:1
** (CompileError) cannot compile code (errors have been logged)
This crashes during compile
try do; :ok; catch; a, b, c when 1 == 1 -> :ok; end
warning: variable "a" is unused (if the variable is not meant to be used, prefix it with an underscore)
└─ iex:1
warning: variable "b" is unused (if the variable is not meant to be used, prefix it with an underscore)
└─ iex:1
warning: variable "c" is unused (if the variable is not meant to be used, prefix it with an underscore)
└─ iex:1
** (CaseClauseError) no case clause matching: [{:a, [version: 0, line: 1], nil}, {:b, [version: 1, line: 1], nil}, {:c, [version: 2, if_undefined: :apply, line: 1], nil}]
(elixir 1.17.2) src/elixir_erl_try.erl:26: :elixir_erl_try.each_clause/2
(elixir 1.17.2) src/elixir_erl_try.erl:17: :elixir_erl_try.reduce_clauses/5
(elixir 1.17.2) src/elixir_erl_pass.erl:151: :elixir_erl_pass.translate/3
(elixir 1.17.2) src/elixir.erl:456: :elixir.quoted_to_erl/4
(elixir 1.17.2) src/elixir.erl:332: :elixir.eval_forms/4
(elixir 1.17.2) lib/module/parallel_checker.ex:112: Module.ParallelChecker.verify/1
(iex 1.17.2) lib/iex/evaluator.ex:332: IEx.Evaluator.eval_and_inspect/3
(iex 1.17.2) lib/iex/evaluator.ex:306: IEx.Evaluator.eval_and_inspect_parsed/3
This emits invalid code and crashes in runtime
for a <- [1, 2], reduce: [] do; a, b when 1 == 1 -> :ok; end
** (ErlangError) Erlang error: {:illegal_pattern, {:call, 11, {:atom, 11, :when}, [{:var, 11, :_a@2}, {:var, 11, :_b@1}, {:op, 11, :==, {:integer, 11, 1}, {:integer, 11, 1}}]}}
(stdlib 5.2.3.1) erl_eval.erl:1232: :erl_eval.match/6
iex:11: (file)
iex:11: (file)
This crashes during translation
defmodule MyModule do
def func(x) do
IO.puts ""
for a <- x, reduce: %{} do
# b when is_integer(b) ->
# IO.puts ""
c, d when is_atom(c) ->
IO.puts ""
end
IO.puts ""
end
end
** (FunctionClauseError) no function clause matching in :v3_core.pattern/2
(compiler 8.4.3) :v3_core.pattern/2
(compiler 8.4.3) v3_core.erl:2357: :v3_core.pattern_list/2
(compiler 8.4.3) v3_core.erl:303: :v3_core.clause/2
(compiler 8.4.3) v3_core.erl:297: :v3_core.clauses/2
(compiler 8.4.3) v3_core.erl:809: :v3_core.expr/2
(compiler 8.4.3) v3_core.erl:643: :v3_core.exprs/2
(compiler 8.4.3) v3_core.erl:306: :v3_core.clause/2
iex:3: (file)
Expected behavior
Compile errors
Metadata
Metadata
Assignees
Labels
No labels