Describe the bug
$ erlc /tmp/bug.erl
Sub pass ssa_opt_type_continue
Function: g/5
/tmp/bug.erl: internal error in pass beam_ssa_opt:
exception error: no function clause matching beam_types:join([])
in function beam_ssa_type:'-opt_continue/4-zlc$^0/2-0-'/2 (beam_ssa_type.erl:470)
in call from beam_ssa_type:opt_continue/4 (beam_ssa_type.erl:471)
in call from beam_ssa_opt:ssa_opt_type_continue/1 (beam_ssa_opt.erl:445)
in call from compile:run_sub_passes_1/3 (compile.erl:1366)
in call from beam_ssa_opt:phase/4 (beam_ssa_opt.erl:123)
in call from beam_ssa_opt:fixpoint/6 (beam_ssa_opt.erl:106)
in call from beam_ssa_opt:run_phases/3 (beam_ssa_opt.erl:92)
To Reproduce
-module(program).
-export([main/1]).
f(_, P) ->
{_, S} = d(P - 1, 0),
if
S =:= 0 ->
g(0,0,0,0,0)
end.
g(_, _, _, _, _) ->
i(0, 0, 0).
d(Q, S) when Q rem 2 =:= 0 ->
d(Q div 2, S + 1);
d(Q, S) ->
{Q, bnot S}.
i(_, _, _) ->
i(0,0,0,0).
i(Base, Exp, Mod, _) ->
_ = case Exp rem 2 of
1 -> 1;
0 -> 0
end,
i(Base, Exp div 2, Mod, 0).
main(_) ->
f(0, 1003).
Apologies for the large reproducer, this bug seems to be incredibly brittle, with small inconsequential changes not triggering it anymore.
Expected behavior
Compiles.
Affected versions
I've only found trunk so far d459618
all stable versions I have access to (e.g. Compiler Explorer) do not manifest this bug
In case this is a weird hardware problem: Linux 6.17.0-35-generic 24.04.1-Ubuntu x86_64
Additional context
This bug is so brittle that even depends on the function name of the d function above.
This does not trigger any internal errors for me:
-module(nobug).
-export([main/1]).
f(_, P) ->
{_, S} = h(P - 1, 0),
if
S =:= 0 ->
g(0,0,0,0,0)
end.
g(_, _, _, _, _) ->
i(0, 0, 0).
h(Q, S) when Q rem 2 =:= 0 ->
h(Q div 2, S + 1);
h(Q, S) ->
{Q, bnot S}.
i(_, _, _) ->
i(0,0,0,0).
i(Base, Exp, Mod, _) ->
_ = case Exp rem 2 of
1 -> 1;
0 -> 0
end,
i(Base, Exp div 2, Mod, 0).
main(_) ->
f(0, 1003).
Notice the only change being renaming function d to function h
Describe the bug
To Reproduce
Apologies for the large reproducer, this bug seems to be incredibly brittle, with small inconsequential changes not triggering it anymore.
Expected behavior
Compiles.
Affected versions
I've only found trunk so far d459618
all stable versions I have access to (e.g. Compiler Explorer) do not manifest this bug
In case this is a weird hardware problem:
Linux 6.17.0-35-generic 24.04.1-Ubuntu x86_64Additional context
This bug is so brittle that even depends on the function name of the
dfunction above.This does not trigger any internal errors for me:
Notice the only change being renaming function d to function h