Closed hansihe closed 4 years ago
This triggers when blocks are used in static value chains.
In a case like this
-module(init).
-export([start/0]).
-import(erlang, [print/1]).
start() ->
Name = <<"Paul">>,
Callback =
fun(Greeting) ->
print(Greeting),
print(Name)
end,
greet(Callback).
greet(Greeter) ->
Greeter(<<"Hello">>).
Workaround:
-module(init).
-export([start/0]).
-import(erlang, [print/1]).
start() ->
Name = void_map(<<"Name">>),
void(),
Callback =
fun(Greeting) ->
print(Greeting),
print(Name)
end,
greet(Callback).
greet(Greeter) ->
Greeter(<<"Hello">>).
void() -> ok.
void_map(A) -> A.
This was fixed by the graph simplification pass rewrite.
When a block capture is part of a chain, and the captured block uses any other value from the same chain, the graph simplification pass may generate invalid IR.
Invalid IR is caught by the graph validation pass.
This issue presents itself when compiling
Elixir.Enum
. It is high priority.