Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failing to parse a nested generator in the inner loop #9

Open
julochrobak opened this issue Jul 8, 2013 · 1 comment
Open

failing to parse a nested generator in the inner loop #9

julochrobak opened this issue Jul 8, 2013 · 1 comment

Comments

@julochrobak
Copy link
Contributor

The following expressions works fine:
[ {b, a} | b <- [0,1], a <- [2,3] ]

but this one fails with a compilation error:
[ {b, a} | b <- [0,1], a <- [ c | c <- [2,3]] ]

{"line":0,"column":0,"error":"unknown identifier 'c'"}
@julochrobak
Copy link
Contributor Author

This is a problem with identifiers scope definition when parsing a comprehension. All identifiers are declared on a global scope and therefore there is a strict mode enabled after the first generator is parsed to enforce that every identifier must be first declared and than used. However, the second example shows that this causes an issue.

Also because of all the identifiers are declared within a global scope, the following comprehensions are valid and work, but don't make much sense:

$ bin/comp '[ b | b <- [ c | c <- [2,3]], c == 3 ]'
[ 2, 3 ]
$

$ bin/comp '[ b | b <- [ c | c <- [2,3], c == 2], b == c ]'
$

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant