From 4236b043e2cddcdb304812bcc0aa8f1d5a5ae27b Mon Sep 17 00:00:00 2001 From: Feoramund <161657516+Feoramund@users.noreply.github.com> Date: Tue, 10 Jun 2025 08:34:07 -0400 Subject: [PATCH] Move negation in `internal_rat_to_float` to end of procedure This should cause a compiler error, due to the assignment to a named return value in a deferred block. Fixes #4565 --- core/math/big/rat.odin | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/math/big/rat.odin b/core/math/big/rat.odin index e0e58b80f5d..e84174d5465 100644 --- a/core/math/big/rat.odin +++ b/core/math/big/rat.odin @@ -378,9 +378,6 @@ internal_rat_to_float :: proc($T: typeid, z: ^Rat, allocator := context.allocato } has_sign := a.sign != b.sign - defer if has_sign { - f = -builtin.abs(f) - } exp := alen - blen a2, b2 := &Int{}, &Int{} @@ -440,6 +437,9 @@ internal_rat_to_float :: proc($T: typeid, z: ^Rat, allocator := context.allocato if math.is_inf(f, 0) { exact = false } + if has_sign { + f = -builtin.abs(f) + } return }