More aggressive freshening to avoid shadowing issues
This commit is contained in:
parent
63d51baaa3
commit
c8153f94a6
@ -1681,8 +1681,18 @@ bottom_up(F, Env, Expr) ->
|
||||
{lam, Xs, B} -> {lam, Xs, bottom_up(F, Env, B)};
|
||||
{'let', X, E, Body} ->
|
||||
E1 = bottom_up(F, Env, E),
|
||||
%% Always freshen user variables to avoid shadowing issues.
|
||||
ShouldFreshen = fun(Y = "%" ++ _) -> maps:is_key(Y, Env);
|
||||
(_) -> true end,
|
||||
case ShouldFreshen(X) of
|
||||
true ->
|
||||
Z = fresh_name(),
|
||||
Env1 = Env#{ Z => E1 },
|
||||
{'let', Z, E1, bottom_up(F, Env1, rename([{X, Z}], Body))};
|
||||
false ->
|
||||
Env1 = Env#{ X => E1 },
|
||||
{'let', X, E1, bottom_up(F, Env1, Body)};
|
||||
{'let', X, E1, bottom_up(F, Env1, Body)}
|
||||
end;
|
||||
{split, Type, X, Cases} -> {split, Type, X, [bottom_up(F, Env, Case) || Case <- Cases]};
|
||||
{nosplit, E} -> {nosplit, bottom_up(F, Env, E)};
|
||||
{'case', Pat, Split} -> {'case', Pat, bottom_up(F, Env, Split)}
|
||||
|
Loading…
x
Reference in New Issue
Block a user