Closed mscharley closed 2 months ago
I think the tuple wrapping happens to early when there is also a guard from
// buggy
fn multi_case() {
let a = "wibble"
let b = "wobble"
case a, b {
// The bug appears here where the generated when guard is wrapped within the tuple
// passed into the branches of the case expression instead of after it
_, "wabble" as c <> rest -> c <> rest
_, _ -> b
}
}
// working
fn single_case() {
let b = "wibble"
case b {
"wabble" as c <> rest -> c <> rest
_ -> b
}
}
-spec multi_case() -> binary().
multi_case() ->
A = <<"wibble"/utf8>>,
B = <<"wobble"/utf8>>,
case {A, B} of
% } should be here ↓ but not here
{_, <<C:6/binary, Rest/binary>> when C =:= <<"wabble"/utf8>>} ->
<<C/binary, Rest/binary>>;
{_, _} ->
B
end.
I wanted to edit the generated erlang and run it directly (but gleam run
always recompiles) via erl
but failed to pass a file as a string into bash off the bat: erl -noinput -eval 'erlang code here.' -s init stop
to confirm if that's the problem/solution.
Oh dear, that is horrid! We'll get this fixed soon
I'm running Gleam 1.2.0 on Linux.
The following code compiles into erlang, but the erlang code is invalid:
Compiler output: