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

Fix some grammar inconsistencies for the '..' range notation. #21374

Merged
merged 1 commit into from
Jan 23, 2015

Conversation

dgrunwald
Copy link
Contributor

This PR is intended as alternative to #20958. It fixes the same grammar inconsistencies, but does not increase the operator precedence of .., leaving it at the same level as the assignment operator.
For previous discussion, see #20811 and #20958.

Grammar changes:

Parser code cleanup:

  • remove RESTRICTION_NO_DOTS
  • make AS_PREC const and follow naming convention
  • make min_prec inclusive

r? nikomatsakis

@rust-highfive
Copy link
Collaborator

r? @nick29581

(rust_highfive has picked a reviewer for you, use r? to override)

@alexcrichton
Copy link
Member

r? @nikomatsakis

Grammar changes:
* allow 'for _ in 1..i {}' (fixes rust-lang#20241)
* allow 'for _ in 1.. {}' as infinite loop
* prevent use of range notation in contexts where only operators of high
  precedence are expected (fixes rust-lang#20811)

Parser code cleanup:
* remove RESTRICTION_NO_DOTS
* make AS_PREC const and follow naming convention
* make min_prec inclusive
@dgrunwald
Copy link
Contributor Author

Rebased onto the big uint->usize change. (though we might want to use u32 for precedences)

@nikomatsakis
Copy link
Contributor

@dgrunwald ok reading this now. On the face of it, it looks much nicer than the previous patch. I haven't had time to play with it yet, but I take it that this means that !..x would not parse, for example? (Not that I know what such a thing should mean just yet.)

@nikomatsakis
Copy link
Contributor

I think I am happy with this version, all things considered. A good compromise.

@pnkfelix
Copy link
Member

looks fine to me too.

@nikomatsakis
Copy link
Contributor

@bors r+ db013f9

@bors
Copy link
Contributor

bors commented Jan 22, 2015

⌛ Testing commit db013f9 with merge 90224cf...

@bors
Copy link
Contributor

bors commented Jan 22, 2015

💔 Test failed - auto-mac-64-nopt-t

@alexcrichton
Copy link
Member

@bors: retry

@bors
Copy link
Contributor

bors commented Jan 23, 2015

⌛ Testing commit db013f9 with merge e9285f9...

bors added a commit that referenced this pull request Jan 23, 2015
This PR is intended as alternative to #20958. It fixes the same grammar inconsistencies, but does not increase the operator precedence of `..`, leaving it at the same level as the assignment operator.
For previous discussion, see #20811 and #20958.

Grammar changes:
* allow `for _ in 1..i {}` (fixes #20241)
* allow `for _ in 1.. {}` as infinite loop
* prevent use of range notation in contexts where only operators of high precedence are expected (fixes #20811)

Parser code cleanup:
* remove `RESTRICTION_NO_DOTS`
* make `AS_PREC` const and follow naming convention
* make `min_prec` inclusive

r? nikomatsakis
@bors bors merged commit db013f9 into rust-lang:master Jan 23, 2015
bors added a commit that referenced this pull request Jan 29, 2015
Note: Do not merge until we get a newer snapshot that includes #21374

There was some type inference fallout (see 4th commit) because type inference with `a..b` is not as good as with `range(a, b)` (see #21672).

r? @alexcrichton
bors added a commit that referenced this pull request Jan 29, 2015
Note: Do not merge until we get a newer snapshot that includes #21374

There was some type inference fallout (see 4th commit) because type inference with `a..b` is not as good as with `range(a, b)` (see #21672).

r? @alexcrichton
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants