-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tuple indexing should handle float tokens specially #28257
Comments
NB. this behaviour was explicitly discussed as part of rust-lang/rfcs#184 that designed this feature. |
/cc @rust-lang/lang, but yes, I thought this was explicitly decided against in the RFC |
(I guess #20287 and #23694 are the same as this; I just didn’t find either of them in my searching.) I really think we should reconsider this. I don’t get the feel that it was so much explicitly decided against in the RFC as that one or possibly two people felt uncomfortable with it and so it was removed from the RFC as the easiest thing to do. I really don’t see any reason for not doing this; it’s not difficult to do, and it makes things do what people expect, as is evidenced by the very way in which the special help message on the error is done. Can anyone present an argument for not doing it? @nikomatsakis, as you preferred not to change the lexer thus at that time a year ago? |
+1
|
On Sat, Sep 05, 2015 at 02:01:02PM -0700, Steve Klabnik wrote:
It was, though I've been bit by it a few times and wondered if we made |
(and @nikomatsakis did even say at that time "we can always add it later" :) ) |
I think Adding it is better tuple_of_tuples.1.1.0.3.0.1 -> heart says it should work :) :) :) |
Triage: this was an explicitly made decision in an RFC, and so I'd argue that it needs an RFC to change. Given that and the lack of comments, I'm going to give this one a close. |
I put up a fix in #70420. I don't think an RFC is going to be required. If the compiler team is on board with the approach, then the lang team can do FCP on the PR. |
tuple.0.0
tokenises as [Ident("tuple"), Dot, Float("0.0")]. At present it produces an “unexpected token” error with a help message along the lines of “try parenthesizing the first index; e.g.,(tuple.0).0
”.This is silly. We should just special-case float literals of the form /\d+.\d+/ and understand them sensibly—that the original one be treated as [Ident("tuple"), Dot, Int("0"), Dot, Int("0")]. It’s not as though there’s any ambiguity (that I see, anyway), and it’s much nicer to handle something automatically where there is no ambiguity and the meaning is perfectly clear, rather than producing a helpful error message.
There’s precedent for this approach to things in the handling of the
&&
token, where the expression&&foo
and the pattern&&foo
are both treated as two&
tokens rather than as a single&&
token.The text was updated successfully, but these errors were encountered: