[erlc] internal consistency check failed
RobinMorisset opened this issue · 4 comments
On master, both with and without 705a255:
-module(call_only).
-compile([export_all]).
f1({X}) when X; (X orelse false) ->
(X orelse {}),
[
{X}#{
f2() orelse X => []
}
|| _ <- []
].
f2() ->
0.
results in an erlc crash with the following message:
call_only:1: function f1/1+27:
Internal consistency check failed - please report this bug.
Instruction: {call_only,3,{f,16}}
Error: {bad_arg_type,
{x,1},
{t_tuple,1,true,#{1 => {t_atom,[false,true]}}},
{t_union,none,none,none,
[{{1,{t_atom,[false]}},
{t_tuple,1,true,#{1 => {t_atom,[false]}}}},
{{1,{t_atom,[true]}},
{t_tuple,1,true,#{1 => {t_atom,[true]}}}}],
none}}:
Somewhat surprisingly, I've not been able to reduce this testcase any more; every single part seems required for the crash to reproduce.
The problem is that two different ways of analyzing the code ends up with types that are equivalent but not the same. Those types of bug often require very specific test cases to reproduce.
There could be quite a while before this pull request gets merged, and it could be revised if we find a better solution. (I've tried to make a more general solution, but I've failed so far.) I've posted the PR now so that the bug will not block you from finding more bugs of similar nature.
If you find similar bugs, please post them in this issue.
Thanks for posting the PR, it is helpful!
Here is another one:
f(_, X) ->
(case X of
<<_, 0>> ->
f();
_ ->
true
end),
X.
f() ->
ok.
Crashes erlc with this message:
consistency:1: function f/2+12:
Internal consistency check failed - please report this bug.
Instruction: {bs_match,{f,0},{y,1},{commands,[{skip,8}]}}
Error: throws_exception:
Neither the linked PR, nor #6415 fixes it.