-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Closed
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
erl_syntax_lib:annotate_bindings is missing code to handle map comprehensions. More specifically there is a case for map_comp missing in vann/2.
To Reproduce
To manifest, use the following module:
-module(foo).
-export([test/1]).
test(String) ->
{ok, Tokens, _} = erl_scan:string(String),
{ok, [Expr]} = erl_parse:parse_exprs(Tokens),
erl_syntax:get_ann(erl_syntax_lib:annotate_bindings(Expr, [])).
Then test its behavior on a simple List comprehension, and compare to the similar Map comprehension:
19> foo:test("[ {X, Y} || {X, Y} <- Pairs ].", ['Pairs']).
[{env,['Pairs']},{bound,[]},{free,['Pairs']}]
20> foo:test("#{ X => Y || {X, Y} <- Pairs }.", ['Pairs']).
[{env,['Pairs']},{bound,['X','Y']},{free,['Pairs','X','Y']}]
Expected behavior
The expected result would be that you get the same set of Bound and Free variables in both cases.
Affected versions
A quick look in Git seems to suggest there has never been any code handling map_comp so all versions since map comprehensions were introduced are likely affected. Tested on OTP27 and OTP28.
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