You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This bug was found in master at commit:
{code:java}
commit a4e8656d1aa4bde0bbfab6a52585add5d7951bd1
Merge: b7d1866d48 75d4701fff
Author: Sverker Eriksson <sverker@erlang.org>
Date: Tue Feb 18 16:38:24 2020 +0100
{code}
Take the following Erlang code:
{code:java}
-module(foo).
-export([bar/2]).
bar(_, Caller) ->
erlang:display({find(module, Caller), find(function, Caller), find(context, Caller)}),
IsFunction = find(function, Caller) /= nil,
case not true of
true ->
ok;
false ->
case (not IsFunction) andalso (find(context, Caller) == match) of
true -> ok;
false -> erlang:display({IsFunction, Caller})
end
end.
-compile({inline, [find/2]}).
find(Key, Map) ->
case Map of
#{Key := Value} -> Value;
#{} -> erlang:error(badmap)
end.
{code}
Compile it with `erlc foo.erl` and now in `erl` type this:
{code:java}
1> foo:bar(baz, #{module => regex, function => nil, context => nil}).
{regex,nil,nil}
{true,#{context=>nil,function=>nil,module=>regex}}
{code}
As you can see, it is saying that `IsFunction` is true but it should be false (as it is not different to nil).
Thank you!
The text was updated successfully, but these errors were encountered:
Thanks for your report! It's a bit too late to get a fix into OTP 23 RC1, but I've got a preliminary one below:
https://github.com/jhogberg/otp/tree/john/compiler/ssa_opt_ne-flipped/ERL-1179
Thank you for the fix. Btw, do you have a straight-forward workaround to suggest? Without this fix, Elixir won't be usable with Erlang/OTP 23 RC1. But if there is a simple fix, I can release a new Elixir version with it. :)
The fix is to not use {{/=}} or {{=/=}}, which might be a bit tricky. :D
Having slept on it I've decided to revert the change that caused this since there's little point to releasing RC1 with such a serious bug present. We'll include a variation of the above fix in RC2.
Ah, thank you! I have figured out that adding a "_ = atom_to_binary(IsFunction, utf8)" also fixes it but you are right, other code may be affected by this, so reverting the optimization before release makes sense.
Original reporter:
josevalim
Affected version:
OTP-23
Fixed in version:
OTP-23.0
Component:
compiler
Migrated from: https://bugs.erlang.org/browse/ERL-1179
The text was updated successfully, but these errors were encountered: