Skip to content

Commit 11af6b8

Browse files
Say that integer literals out of the u128 range are a parse-time error
1 parent 47996f0 commit 11af6b8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/expressions/literal-expr.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
>    | [BYTE_LITERAL]\
99
>    | [BYTE_STRING_LITERAL]\
1010
>    | [RAW_BYTE_STRING_LITERAL]\
11-
>    | [INTEGER_LITERAL]\
11+
>    | [INTEGER_LITERAL][^out-of-range]\
1212
>    | [FLOAT_LITERAL]\
1313
>    | [BOOLEAN_LITERAL]
14+
>
15+
> [^out-of-range]: A value ≥ 2<sup>128</sup> is not allowed.
1416
1517
A _literal expression_ is an expression consisting of a single token, rather than a sequence of tokens, that immediately and directly denotes the value it evaluates to, rather than referring to it by name or some other evaluation rule.
1618

@@ -68,6 +70,7 @@ The value of the expression is determined from the string representation of the
6870
* Any underscores are removed from the string.
6971

7072
* The string is converted to a `u128` value as if by [`u128::from_str_radix`] with the chosen radix.
73+
If the value does not fit in `u128`, the expression is rejected by the parser.
7174

7275
* The `u128` value is converted to the expression's type via a [numeric cast].
7376

0 commit comments

Comments
 (0)