-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Allow lexer to recover from some homoglyphs #62963
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹⋅s⁻² | ||
//~^ ERROR expected at least one digit in exponent | ||
//~| ERROR unknown start of token: \u{2212} | ||
//~| ERROR cannot subtract `{integer}` from `{float}` | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,5 +14,14 @@ help: Unicode character '−' (Minus Sign) looks like '-' (Minus/Hyphen), but it | |
LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e-11; // m³⋅kg⁻¹⋅s⁻² | ||
| ^ | ||
|
||
error: aborting due to 2 previous errors | ||
error[E0277]: cannot subtract `{integer}` from `{float}` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I think we should do the substitution earlier, so it works in literals too, not just full tokens. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Unicode stuff is legal inside string literals, so I'm not sure there's a single earlier point where this can be done. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's something I want to do (precisely for string literals) if and only if there is one unambiguous way of parsing it (like somebody copy-pasted code from a PDF and ends up with |
||
--> $DIR/issue-49746-unicode-confusable-in-float-literal-expt.rs:1:53 | ||
| | ||
LL | const UNIVERSAL_GRAVITATIONAL_CONSTANT: f64 = 6.674e−11; // m³⋅kg⁻¹⋅s⁻² | ||
| ^ no implementation for `{float} - {integer}` | ||
| | ||
= help: the trait `std::ops::Sub<{integer}>` is not implemented for `{float}` | ||
|
||
error: aborting due to 3 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0277`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fn main() { | ||
println!(""); //~ ERROR unknown start of token: \u{37e} | ||
let x: usize = (); //~ ERROR mismatched types | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
error: unknown start of token: \u{37e} | ||
--> $DIR/recover-from-homoglyph.rs:2:17 | ||
| | ||
LL | println!(""); | ||
| ^ | ||
help: Unicode character ';' (Greek Question Mark) looks like ';' (Semicolon), but it is not | ||
| | ||
LL | println!(""); | ||
| ^ | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/recover-from-homoglyph.rs:3:20 | ||
| | ||
LL | let x: usize = (); | ||
| ^^ expected usize, found () | ||
| | ||
= note: expected type `usize` | ||
found type `()` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
Uh oh!
There was an error while loading. Please reload this page.