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

Scope of pattern variables in join clause #9210

Closed
gafter opened this issue Feb 25, 2016 · 2 comments
Closed

Scope of pattern variables in join clause #9210

gafter opened this issue Feb 25, 2016 · 2 comments
Assignees
Labels
0 - Backlog Area-Compilers New Language Feature - Pattern Matching Pattern Matching Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented

Comments

@gafter
Copy link
Member

gafter commented Feb 25, 2016

The expression in a join clause, i.e. e in ... join x in e ..., does not turn into a lambda body. This expression needs to define a scope for any pattern variables that are declared in that expression. The scope of those pattern variables does not extend outside that expression.

@AlekseyTs
Copy link
Contributor

I disagree with this. Given that

A query expression with a join clause without an into followed by a select clause
from x1 in e1
join x2 in e2 on k1 equals k2
select v
is translated into
( e1 ) . Join( e2 , x1 => k1 , x2 => k2 , ( x1 , x2 ) => v )
A query expression with a join clause without an into followed by something other than a select clause
from x1 in e1
join x2 in e2 on k1 equals k2 
…
is translated into
from * in ( e1 ) . Join(
    e2 , x1 => k1 , x2 => k2 , ( x1 , x2 ) => new { x1 , x2 })
…
A query expression with a join clause with an into followed by a select clause
from x1 in e1
join x2 in e2 on k1 equals k2 into g
select v
is translated into
( e1 ) . GroupJoin( e2 , x1 => k1 , x2 => k2 , ( x1 , g ) => v )
A query expression with a join clause with an into followed by something other than a select clause
from x1 in e1
join x2 in e2 on k1 equals k2 into g
…
is translated into
from * in ( e1 ) . GroupJoin(
    e2 , x1 => k1 , x2 => k2 , ( x1 , g ) => new { x1 , g })

e2 should share scope with the scope that contains entire query expression, similar to e1.

@gafter
Copy link
Member Author

gafter commented Feb 26, 2016

@AlekseyTs Sounds good to me. I like your proposed scope rule here.

AlekseyTs added a commit to AlekseyTs/roslyn that referenced this issue Feb 26, 2016
@AlekseyTs AlekseyTs added the Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented label Feb 26, 2016
@AlekseyTs AlekseyTs assigned gafter and unassigned AlekseyTs Feb 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0 - Backlog Area-Compilers New Language Feature - Pattern Matching Pattern Matching Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
None yet
Development

No branches or pull requests

2 participants