From 9f30b56e1370acb046bb7f0e02945b66bc5eea4e Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Wed, 28 May 2025 13:01:49 +0200 Subject: [PATCH] Deprecate `f32`, `f64` and `f128` suffixes. --- releasenotes.md | 1 + src/compiler/parse_expr.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/releasenotes.md b/releasenotes.md index fd013c502..08ae9861b 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -20,6 +20,7 @@ - `@jump` now included in `--list-attributes` #2155. - Add `$$matrix_mul` and `$$matrix_transpose` builtins. - Add `d` as floating point suffix for `double` types. +- Deprecate `f32`, `f64` and `f128` suffixes. ### Fixes - Assert triggered when casting from `int[2]` to `uint[2]` #2115 diff --git a/src/compiler/parse_expr.c b/src/compiler/parse_expr.c index 2a48c75da..852d599cd 100644 --- a/src/compiler/parse_expr.c +++ b/src/compiler/parse_expr.c @@ -1822,6 +1822,14 @@ static Expr *parse_double(ParseContext *c, Expr *left) bool is_hex = original[0] == '0' && 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) + { + const char *last = c->data.lex_start + c->data.lex_len - 3; + if (last[0] == 'f' && ((last[1] == '3' && last[2] == '2') || (last[1] == '6' && last[2] == '4'))) + { + SEMA_DEPRECATED(number, "Float number suffixes are deprecated, use 'f' and 'd' instead.'"); + } + } Float f = is_hex ? float_from_hex(original, &err) : float_from_string(original, &err); if (f.type == TYPE_POISONED) {