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

Parser inconsistency in for loop iter expression place #31423

Closed
makoConstruct opened this issue Feb 5, 2016 · 1 comment
Closed

Parser inconsistency in for loop iter expression place #31423

makoConstruct opened this issue Feb 5, 2016 · 1 comment

Comments

@makoConstruct
Copy link

http://is.gd/4PtH5V

@huonw
Copy link
Member

huonw commented Feb 5, 2016

This is by design; the for _ A { i: 3 }.iter() { version is parsing the A (by itself) as the iterator, with the following { the start of the body of the loop. This is important to allow things like

let iter = ...;
for _ in iter { ... }

without requiring disambiguating parens: for _ in (iter) { ... }. We chose this arrangement because we felt that for _ in identifier { ... } and if identifer { ... } (etc.) were more common than constructing a struct directly in the iterator/condition.

Thanks for filing!

@huonw huonw closed this as completed Feb 5, 2016
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

2 participants