Gradualizer
Gradualizer copied to clipboard
Variable scoping issue with funs
Hi,
I discovered an issue related to variable scoping where variables inside of a lambda affect the external scope.
A reproducible test case is the following:
-module(error).
-compile([export_all, nowarn_export_all]).
%% error.erl: The variable on line 17 at column 5 is expected to have type [T] but it has type #{any() => any()}
%%
%% Variable =:= Variable
%% end, []),
%% Variable = lists:append(NotImportant, []),
%% ^^^^^^^^
%%
-spec should_pass_variable_not_shadowed() -> list().
should_pass_variable_not_shadowed() ->
NotImportant = lists:filter(fun(X) ->
Variable = maps:from_list(X),
Variable =:= Variable
end, []),
Variable = lists:append(NotImportant, []),
Variable.