Variable bound inside of function call used in case is not in scope in clauses
KronicDeth opened this issue · 0 comments
KronicDeth commented
encode_jer({choice,Choices},{Alt,Value}) ->
case is_map_key(AltBin = atom_to_binary(Alt,utf8),Choices) of
true ->
EncodedVal = encode_jer(maps:get(AltBin,Choices),Value),
#{AltBin => EncodedVal};
false ->
exit({error,{asn1,{invalid_choice,Alt,Choices}}})
end;
Errors with
stderr: Compiling /Users/runner/work/lumen/otp/lib/asn1/src/asn1rtt_jer.erl
error: could not resolve variable
┌─ /Users/runner/work/lumen/otp/lib/asn1/src/asn1rtt_jer.erl:116:46
│
116 │ EncodedVal = encode_jer(maps:get(AltBin,Choices),Value),
│ ^^^^^^ not bound in scope
error: could not resolve variable
┌─ /Users/runner/work/lumen/otp/lib/asn1/src/asn1rtt_jer.erl:117:15
│
117 │ #{AltBin => EncodedVal};
│ ^^^^^^ not bound in scope
error: parsing failed
Failed /Users/runner/work/lumen/otp/lib/asn1/src/asn1rtt_jer.erl
It appears the Erlang/BEAM allow AltBin
to be bound inside the argument to is_map_key
as the argument to case
and then used in the clauses, but EIR does not.