From d43d7100afc718278c67fe7bd2d8a90dd9a278e9 Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Mon, 3 Nov 2025 21:31:47 +0100 Subject: [PATCH] Fix division-by-zero checks on `a /= 0` and `b /= 0f` #2558. --- releasenotes.md | 1 + src/compiler/sema_expr.c | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/releasenotes.md b/releasenotes.md index 0d7bfccdb..087547574 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -12,6 +12,7 @@ - `Foo.is_eq` would return false if the type was a `typedef` and had an overload, but the underlying type was not comparable. - Remove division-by-zero checks for floating point in safe mode #2556. - Fix division-by-zero checks on `a /= 0` and `b /= 0f` #2558. +- Fix fmod `a %= 0f`. ### Stdlib changes diff --git a/src/compiler/sema_expr.c b/src/compiler/sema_expr.c index d78a4d997..a6e94b635 100644 --- a/src/compiler/sema_expr.c +++ b/src/compiler/sema_expr.c @@ -7166,6 +7166,7 @@ static bool sema_expr_analyse_op_assign(SemaContext *context, Expr *expr, Expr * { case BINARYOP_MULT_ASSIGN: case BINARYOP_DIV_ASSIGN: + case BINARYOP_MOD_ASSIGN: break; case BINARYOP_BIT_AND_ASSIGN: case BINARYOP_BIT_OR_ASSIGN: @@ -7177,9 +7178,6 @@ static bool sema_expr_analyse_op_assign(SemaContext *context, Expr *expr, Expr * case BINARYOP_SUB_ASSIGN: is_add_sub = true; break; - case BINARYOP_MOD_ASSIGN: - int_only = true; - break; case BINARYOP_SHL_ASSIGN: case BINARYOP_SHR_ASSIGN: is_shift = true;