-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugIssue is reported as a bugIssue is reported as a bugteam:VMAssigned to OTP team VMAssigned to OTP team VM
Description
Describe the bug
Take this code:
-module(clean_minimal).
-export([test/0]).
%% This triggers the bug
buggy(X) ->
_ = id(X),
case X =:= <<"a">> orelse X =:= <<"b">> of
false -> outside;
true ->
Y = case X of <<"a">> -> 1; _ -> 2 end,
{inside, Y}
end.
id(Z) -> Z.
test() ->
io:format("buggy(<<\"c\">>) = ~p~n", [buggy(<<"c">>)]).Now compile and execute it:
$ erlc clean_minimal.erl && erl -noshell -eval "clean_minimal:test(), init:stop()" && erlc +no_type_opt clean_minimal.erl && erl -noshell -eval "io:format(\"~nWith +no_type_opt:~n\"), clean_minimal:test(), init:stop()"It emits:
buggy(<<"c">>) = {inside,2}
With +no_type_opt:
buggy(<<"c">>) = outside
Showing the type optimisation makes it enter the wrong branch.
Affected versions
Checked only on Erlang/OTP 28 [erts-16.2]
Additional context
Originally reported here: elixir-lang/elixir#15069
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugIssue is reported as a bugIssue is reported as a bugteam:VMAssigned to OTP team VMAssigned to OTP team VM