-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Labels
Milestone
Description
Environment
- Elixir & Erlang/OTP versions (elixir --version): Elixir 1.9.0-dev (f56a92202) (compiled with Erlang/OTP 21)
Current behavior
I got a crash on a binary pattern match that's wrong (we can't refer function args like that). I'm not sure if it's worth fixing, but I thought I'll mention this anyway, in case it points to other issues.
defmodule M do
def decode_int(size, <<value::size(size)-unit(8)>>) do
value
end
end
~% elixir a.ex
Function: decode_int/2
** (CompileError) a.ex: internal error in sys_core_dsetel;
crash reason: {case_clause,
{'EXIT',
{{case_clause,#{0 => 1,1 => 1}},
[{sys_core_dsetel,visit_pat,3,
[{file,"sys_core_dsetel.erl"},{line,239}]},
{sys_core_dsetel,visit_pats,3,
[{file,"sys_core_dsetel.erl"},{line,215}]},
{sys_core_dsetel,visit,2,[{file,"sys_core_dsetel.erl"},{line,212}]},
{lists,mapfoldl,3,[{file,"lists.erl"},{line,1354}]},
{sys_core_dsetel,visit,2,[{file,"sys_core_dsetel.erl"},{line,188}]},
{sys_core_dsetel,visit,2,[{file,"sys_core_dsetel.erl"},{line,126}]},
{sys_core_dsetel,visit_module_1,3,
[{file,"sys_core_dsetel.erl"},{line,80}]},
{sys_core_dsetel,visit_module,1,
[{file,"sys_core_dsetel.erl"},{line,76}]}]}}}
in function compile:'-select_passes/2-anonymous-2-'/3 (compile.erl, line 585)
in call from compile:'-internal_comp/5-anonymous-1-'/3 (compile.erl, line 349)
in call from compile:fold_comp/4 (compile.erl, line 376)
in call from compile:internal_comp/5 (compile.erl, line 360)
in call from compile:'-do_compile/2-anonymous-0-'/2 (compile.erl, line 177)
in call from elixir_erl_compiler:compile/4 (src/elixir_erl_compiler.erl, line 52)
in call from elixir_erl:load_form/5 (src/elixir_erl.erl, line 444)
in call from elixir_erl_compiler:'-spawn/2-fun-0-'/3 (src/elixir_erl_compiler.erl, line 12)
(stdlib) lists.erl:1338: :lists.foreach/2
(elixir) src/elixir_erl_compiler.erl:12: anonymous fn/3 in :elixir_erl_compiler.spawn/2
(elixir) lib/code.ex:767: Code.require_file/2
FWIW, Erlang does this:
-module(bug).
-export([decode_int/2]).
decode_int(Size, <<Value:Size/unit:8>>) ->
Value.
===> Compiling src/bug.erl failed
src/bug.erl:4: variable 'Size' is unbound
Expected behavior
Better error message.