erlang/otp

[erlc] Internal consistency check failed

RobinMorisset opened this issue ยท 4 comments

On master:

f(
    X,
    <<X>>,
    X
) when true; (0 rem 0) ->
    (-2147483648 < X) orelse
        [0 || _ <- X].

crashes erlc with the following error message:

consistency_call_1:1: function f/3+17:
  Internal consistency check failed - please report this bug.
  Instruction: {call_only,1,{f,13}}
  Error:       {bad_arg_type,{x,0},
                             {t_integer,{0,255}},
                             {t_number,{'-inf',-2147483648}}}:

Another testcase with the same error message:

f(Y, X, <<X>>, Y) when true; X ->
    [
        0
     || _ <-
            (case Y of
                _ when (X =< (bnot 0)) ->
                    X
            end)
    ].

This testcase has a very similar but slightly different error message, so I don't know whether it is the same bug or another one:

f(X) ->
    <<
        0
     || #{X := _} <-
            (case (true =/= X) of
                X ->
                    X;
                false ->
                    X
            end),
        _ <- []
    >>.

results in

consistency_check_call_2:1: function f/1+26:
  Internal consistency check failed - please report this bug.
  Instruction: {call_last,3,{f,9},2}
  Error:       {bad_arg_type,{x,2},any,{t_atom,[false,true]}}:

Here is another similar looking one that is not fixed by that PR:

f(X) when (X /= []) /= is_port(0 div 0) ->
    [X || _ <- []].

results in

consistency_5:1: function f/1+10:
  Internal consistency check failed - please report this bug.
  Instruction: {call_only,2,{f,7}}
  Error:       {bad_arg_type,{x,1},
                             nil,
                             {t_union,{t_atom,any},
                                      {t_cons,any,any},
                                      {t_number,any},
                                      {t_tuple,0,false,#{}},
                                      other}}:

Should I make it a separate issue, or is it related?

That's a separate issue.