Closed
Description
fn main() {
let a = (1, 2, 3);
println!("{}", a.1lolololol);
}
Expected:
ERROR: tuple index with a suffix is invalid
Got:
Output: 2\n
All thanks to: https://linuxrocks.online/@carl/101569506337640753
UPD:
The same error arises with tuple struct:
struct X(i32,i32,i32);
fn main() {
let a = X(1, 2, 3);
let b = a.1lolololol;
println!("{}", b);
}
Expected:
ERROR: tuple index with a suffix is invalid
Got:
Output: 2\n
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
[-]Syntax: ignoring text after tuple index[/-][+]Syntax: ignoring text after tuple index (a.1lolololol)[/+][-]Syntax: ignoring text after tuple index (a.1lolololol)[/-][+]Syntax: ignoring text after tuple/tuple struct index (a.1lolololol)[/+]estebank commentedon Mar 25, 2019
Introduced in 1.27. Output in 1.26:
[-]Syntax: ignoring text after tuple/tuple struct index (a.1lolololol)[/-][+]Syntax: ignoring tuple index with a suffix (a.1lolololol)[/+]varkor commentedon Mar 25, 2019
I have a fix for this.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:
so that even without the custom error message, the suffix is still taken into account when resolving the field name.
estebank commentedon Mar 25, 2019
@varkor I have the fix, just waiting for
--bless
to finish:Rollup merge of rust-lang#59421 - estebank:tuple-index-suffix, r=petr…
Rollup merge of rust-lang#59421 - estebank:tuple-index-suffix, r=petr…
Rollup merge of rust-lang#59421 - estebank:tuple-index-suffix, r=petr…
Centril commentedon Apr 20, 2019
cc #59553