Reserved float literals are accepted
- Dominant language
- Rust
- Stars
- 934
- Forks
- 135
- PR merge metrics
- No merged PRs in 30d
Description
Binary, octal, and hex literals immediately followed by a `.` (and then not followed by `.` `_` or XID_Start) are reserved and generate a parse error, but proc-macro2 is accepting them (generally as three separate tokens).
```rust
use std::str::FromStr;
fn main() {
for input in [
"0b101.010",
"0x567.89",
"0o123.45",
] {
println!("{:?}", proc_macro2::TokenStream::from_str(input));
}
}
```
outputs:
```
Ok(TokenStream [Literal { lit: 0b101 }, Punct { char: '.', spacing: Alone }, Literal { lit: 010 }])
Ok(TokenStream [Literal { lit: 0x567 }, Punct { char: '.', spacing: Alone }, Literal { lit: 89 }])
Ok(TokenStream [Literal { lit: 0o123 }, Punct { char: '.', spacing: Alone }, Literal { lit: 45 }])
```
but I would expect it to be a parse error.
Checked [here](https://github.com/rust-lang/rust/blob/eeb94be79adc9df7a09ad0b2421f16e60e6d932c/compiler/rustc_ast/src/util/literal.rs#L272-L274) in the compiler. It parses them as floats, and then later checks the base.
Using `proc-macro2 1.0.106`.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.