Compiler crash in pass beam_ssa_opt, sub pass ssa_opt_private_append
bjorng opened this issue · 3 comments
bjorng commented
Describe the bug
The compiler crashes like this when compiling the module shown below:
Sub pass ssa_opt_private_append
beam_ssa_private_append_crash.erl: internal error in pass beam_ssa_opt:
exception error: no function clause matching beam_ssa_private_append:patch_literal_term([],[self],5)
in function beam_ssa_private_append:patch_appends_ret/3 (beam_ssa_private_append.erl, line 462)
in call from beam_ssa_private_append:patch_appends_f/5 (beam_ssa_private_append.erl, line 416)
in call from beam_ssa_private_append:'-patch_appends/3-anonymous-2-'/3 (beam_ssa_private_append.erl, line 390)
in call from maps:fold_1/4 (maps.erl, line 416)
in call from beam_ssa_private_append:private_append/3 (beam_ssa_private_append.erl, line 72)
in call from compile:run_sub_passes_1/3 (compile.erl, line 424)
in call from beam_ssa_opt:run_phases/3 (beam_ssa_opt.erl, line 75)
To Reproduce
Compile the following module:
-module(beam_ssa_private_append_crash).
-compile([export_all]).
foo() ->
<<(bar(ok))/binary>>.
bar(#{}) ->
[];
bar(_) ->
<<>>.
Expected behavior
The compilation should succeed.
Affected versions
The current master
branch.
bjorng commented
As a bonus, here is how the currently not covered line 548 in beam_ssa_private_append
can be covered:
cover_beam_ssa_private_append_line_548() ->
<<(try
<<>> = ok
catch
throw:#{} ->
<<>>;
_ ->
ok
end)/binary>>.