erlang / otp

Erlang/OTP
http://erlang.org
Apache License 2.0
11.35k stars 2.95k forks source link

UU compiler project (GH-6599) #7342

Open bjorng opened 1 year ago

bjorng commented 1 year ago

Here are the examples from #6599 that were not fixed by #7330.

To Reproduce Compile one the following examples:

%% Never finishes.
f(X) when true; X ->
    - maybe
        <<>> ?= X,
        f(maybe
            0 ?= ([] =< ok)
        end),
        <<>> ?= ok
    else
        false  ->
            X;
        0  ->
            X
    end.
%% Never finishes.
f(_, []) ->
    0;
f(X, _) ->
    ?MODULE:foo(
        <<>> =
            try f(ok, X) + 0 of
                X ->
                    X
            catch
                _ ->
                    X
            end
    );
f(_, _) ->
    ok.

EDITED: Moved an example to #7354.

bjorng commented 1 year ago

Additional examples from #7360 with some optimizations disabled.

Compiling with erlc +no_ssa_opt:

f(_V0) ->
    [0 || not (_V0 > (0 bsl erlang:adler32(true = (_V7 = (ok < _V0))))), _V7].

results in the following message:

test21380:1: function f/1+20:
  Internal consistency check failed - please report this bug.
  Instruction: {test,is_eq_exact,{f,10},[{y,0},{atom,true}]}
  Error:       {type_conflict,{t_atom,[ok]},none}:

Compile with erlc +no_copt +no_ssa_opt:

f() ->
    <<_V0/utf32>> = foo,
    [
        0
     || _ <- bar,
        _V4 = (_V2 = _V0) > baz,
        _V4 =
            case _V2 bxor _V2 of
                _ -> ok
            end
    ].

Compile with erlc +no_ssa_opt:

f(_V3) ->
    case foo =< _V3 of
        _V4 when _V4 andalso {trunc(_V3), _V4 orelse bar} ->
            ok
    end.