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

Macros with for loop arguments are parsed differently in comprehensions #18935

Closed
simonster opened this issue Oct 14, 2016 · 3 comments
Closed
Assignees
Labels
parser Language parsing and surface syntax

Comments

@simonster
Copy link
Member

These work:

[for i = 1:10 end for i = 1:10]
@inbounds for i = 1:10 end
[@inbounds(for i = 1:10 end) for i = 1:10]
[@inbounds begin 
    for i = 1:10 end
end for i = 1:10]

These do not:

[@inbounds for i = 1:10 end for i = 1:10]
[begin
   @inbounds for i = 1:10 end
end for i = 1:10]
@simonster simonster added the parser Language parsing and surface syntax label Oct 14, 2016
@JeffBezanson
Copy link
Member

The extra parens seem advisable there.

@simonster
Copy link
Member Author

simonster commented Oct 15, 2016

I agree that [@inbounds for i = 1:10 end for i = 1:10] is not so clear, but code in a begin/end block inside a comprehension seems like it should have the same rules as code in a begin/end block outside of a comprehension.

@StefanKarpinski
Copy link
Member

Related: #18650.

@JeffBezanson JeffBezanson self-assigned this Jun 9, 2017
JeffBezanson added a commit that referenced this issue Jul 22, 2017
- `end` should only be special inside indexing expressions, not cat
- Blocks introduced by words (e.g. `if`, `begin`) should revert to
  normal parsing context, so `for` is no longer special. Fixes #18935
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parser Language parsing and surface syntax
Projects
None yet
Development

No branches or pull requests

3 participants