Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRange expressions: discrepancies between rustc and parser-lalr #28785
Comments
This comment has been minimized.
This comment has been minimized.
|
Looking through #20811, I see two more cases where fn rangefrom_compare() {
1.. == (1..); // rustc syntax error, parser-lalr parses as (1..) == (1..)
}
fn compare_rangeto() {
(..1) == ..1; // rustc syntax error, parser-lalr parses as (..1) == (..1)
} |
huonw
added
A-grammar
I-nominated
T-lang
labels
Oct 1, 2015
nikomatsakis
referenced this issue
Oct 1, 2015
Open
Field access of block: discrepancy between parser-lalr and rustc #28379
This comment has been minimized.
This comment has been minimized.
|
triage: P-medium This is a backwards incompat issue, but feels like an edge case. Nonetheless we should definitely fix it! |
rust-highfive
added
P-medium
and removed
I-nominated
labels
Oct 1, 2015
This comment has been minimized.
This comment has been minimized.
|
Can you explain why you think that I would expect On all other examples, I'd say the rustc behavior is correct. The decision in #21374 was: Comparing ranges needs parentheses: the attempt to give Admittedly, having |
This comment has been minimized.
This comment has been minimized.
|
Regarding let x = {
{}
-1
}(Rust ignores newlines outside of string-literals, AFAIK.)
@nikomatsakis made some comments to this effect here: Of course, FWIW, I noticed that the current nightly Rust compiler is now parsing |
This comment has been minimized.
This comment has been minimized.
|
That makes sense; I didn't realize we had that rule about It also fits what I wrote in #25119: In a formal grammar, the restrictions around
Is there any way to do this with the |
This comment has been minimized.
This comment has been minimized.
|
I think we can reduce the problem to: expr
: DOTDOT
| expr DOT ID
| ID
{}
;We need to reject (Aside: I'm finding Some parser generators (e.g. menhir) allowing parameterizing rules. e.g. Maybe a formal grammar could have a single (Also: I get the impression that the nonparen restriction class might be going away. It's needed only for the placement new |
This comment has been minimized.
This comment has been minimized.
|
Actually, I'm starting to think that the rustc behavior might not be ideal: it interacts badly with lambda syntax. Rust currently has 7 non-associative operators: Rustc currently rejects Lambdas have the same "precedence inversion" problem that I tried to avoid for (unary) For example, This gets especially problematic when the programmer assumes the lambda body is an expression, but the expression actually ends earlier. Is One solution would be to parse The other option would be to disallow lambdas from appearing as left-hand-operand of a binary operator (just like we already disallow blocks in such a position). |
This comment has been minimized.
This comment has been minimized.
|
I think we should disallow lambdas from appearing as left-hand-operand of a binary operator or as operand of a suffix expression. |
This comment has been minimized.
This comment has been minimized.
|
On Thu, Nov 05, 2015 at 09:59:14AM -0800, Ryan Prichard wrote:
Just wanted to point out that LALRPOP supports this sort of |
brson
added
the
E-mentor
label
Aug 4, 2016
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis can mentor. Needs investigation into the correct grammar. |
brson
added
the
I-wrong
label
Aug 4, 2016
nikomatsakis
added
I-needs-decision
and removed
I-wrong
labels
Aug 4, 2016
brson
added
the
I-wrong
label
Aug 4, 2016
dgrunwald
referenced this issue
Oct 21, 2016
Open
Tracking issue for stmt_expr_attributes: Add attributes to expressions, etc. #15701
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis Could you either provide some instructions here, or otherwise unmark as E-mentor? |
Mark-Simulacrum
added
C-bug
and removed
I-wrong
labels
Jul 24, 2017
steveklabnik
removed
the
E-mentor
label
Oct 31, 2018
This comment has been minimized.
This comment has been minimized.
|
Triage; is parser-lalr still a thing? is this issue relevant? also, removing e-mentor |
rprichard commentedOct 1, 2015
I'd guess that the last test case here is a
rustcbug, but I don't know about the others.Also see #25119.