-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Syntax: ignoring tuple index with a suffix (a.1lolololol) #59418
Comments
Introduced in 1.27. Output in 1.26:
|
Edit: ah, @estebank's already self-assigned — I'll leave it to them. One thing I would do, as well as introducing a custom error message, is make sure the suffix isn't ignored in the main code path. E.g. rust/src/libsyntax/parse/parser.rs Lines 3210 to 3215 in 7a4df3b
would be better changed to something like: token::Literal(token::Integer(name), suf) => {
let span = self.span;
self.bump();
// Affix the suffix to the integer. This means that the suffix will
// be treated as part of the field name and will not simply be ignored.
let name = name.as_str().to_string() + suf.map_or("", |s| s.as_str().get());
let field = ExprKind::Field(e, Ident::new(Symbol::intern(&name), span));
e = self.mk_expr(lo.to(span), field, ThinVec::new());
} so that even without the custom error message, the suffix is still taken into account when resolving the field name. |
@varkor I have the fix, just waiting for
|
…ochenkov Reject integer suffix when tuple indexing Fix rust-lang#59418. r? @varkor
…ochenkov Reject integer suffix when tuple indexing Fix rust-lang#59418. r? @varkor
…ochenkov Reject integer suffix when tuple indexing Fix rust-lang#59418. r? @varkor
cc #59553 |
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=4280ded6698f9f9f3877ad0498769cb7
Expected:
Got:
All thanks to: https://linuxrocks.online/@carl/101569506337640753
UPD:
The same error arises with tuple struct:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=ad7f39e8edad0d98f2919bd4fdfded30
Expected:
Got:
The text was updated successfully, but these errors were encountered: