Skip to content
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

The rust compiler is permissive of f32 and f64 suffix #922

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/tokens.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ literal_. The grammar for recognizing the two kinds of literals is mixed.
> INTEGER_SUFFIX :\
>       `u8` | `u16` | `u32` | `u64` | `u128` | `usize`\
>    | `i8` | `i16` | `i32` | `i64` | `i128` | `isize`
>    | `f32` | `f64`

An _integer literal_ has one of four forms:

Expand All @@ -368,7 +369,10 @@ Like any literal, an integer literal may be followed (immediately,
without any spaces) by an _integer suffix_, which forcibly sets the
type of the literal. The integer suffix must be the name of one of the
integral types: `u8`, `i8`, `u16`, `i16`, `u32`, `i32`, `u64`, `i64`,
`u128`, `i128`, `usize`, or `isize`.
`u128`, `i128`, `f32`,`f64`, `usize`, or `isize`.

Note the suffix of `f32` and `f64` ensures that the literal has a floating point type.
Even when it would otherwise be lexed as an integer.

The type of an _unsuffixed_ integer literal is determined by type inference:

Expand Down