-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Labels
Description
Elixir and Erlang/OTP versions
Erlang/OTP 27 [erts-15.2.7.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [jit:ns]
Elixir 1.20.0-dev (dd45d96) (compiled with Erlang/OTP 27)
Operating system
Alpine Linux Edge
Current behavior
Attempting to match an already bound binary variable and binding the same name, in a binary segment whose specifier references the previously bound value, results in an Erlang interpreter/compiler error.
iex(1)> a = "123"
iex(2)> <<a::binary-size(byte_size(a) - 1), b>> = "123"
** (ErlangError) Erlang error: {:illegal_pattern, {:bin, 2, [{:bin_element, 2, {:var, 2, :_a@1}, {:var, 2, :_a@1}, [:binary]}, {:bin_element, 2, {:var, 2, :_b@1}, :default, [:integer]}]}}
(stdlib 6.2.2.2) erl_eval.erl:1414: :erl_eval.match/6
iex:2: (file)
Expected behavior
Either display an error indicating such pattern isn't allowed, or allow referencing the old value.