diff --git a/releasenotes.md b/releasenotes.md index 833391983..db609263b 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -17,6 +17,7 @@ - Detect recursive creation of generics #2366. - Compiler assertion when defining a function with return type untyped_list #2368. - Compiler assert when using generic parameters list without any parameters. #2369 +- Parsing difference between "0x00." and "0X00." literals #2371 ### Stdlib changes - Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`. diff --git a/src/compiler/parse_expr.c b/src/compiler/parse_expr.c index cfc6ca869..271d5f0db 100644 --- a/src/compiler/parse_expr.c +++ b/src/compiler/parse_expr.c @@ -1883,7 +1883,7 @@ static Expr *parse_double(ParseContext *c, Expr *left, SourceSpan lhs_start) char *err; Expr *number = EXPR_NEW_TOKEN(EXPR_CONST); const char *original = symstr(c); - bool is_hex = original[0] == '0' && original[1] == 'x'; + bool is_hex = original[0] == '0' && (original[1] == 'x' || original[1] == 'X'); // This is set to try to print in a similar manner as the input. number->const_expr.is_hex = is_hex; if (c->data.lex_len > 3) diff --git a/test/test_suite/floats/parse_hex_float.c3 b/test/test_suite/floats/parse_hex_float.c3 new file mode 100644 index 000000000..a1114215a --- /dev/null +++ b/test/test_suite/floats/parse_hex_float.c3 @@ -0,0 +1,4 @@ +fn void main() +{ + $echo $typeof(0X00.).nameof; // #error: Hex floating points must end with 'p' or 'P' +}