From 485b414fcec195bf217aba252e97c3c71f9bf489 Mon Sep 17 00:00:00 2001 From: ringabout <43030857+ringabout@users.noreply.github.com> Date: Thu, 6 Feb 2025 02:37:13 +0800 Subject: [PATCH] fixes #24666; Compilation error when formatting a complex number (#24667) fixes #24666 ref https://github.com/nim-lang/Nim/pull/22924 --- lib/pure/complex.nim | 2 +- tests/stdlib/tcomplex.nim | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/pure/complex.nim b/lib/pure/complex.nim index 77f2b35bef..b57bcdc533 100644 --- a/lib/pure/complex.nim +++ b/lib/pure/complex.nim @@ -33,7 +33,7 @@ runnableExamples: {.push checks: off, line_dir: off, stack_trace: off, debugger: off.} # the user does not want to trace a part of the standard library! -import std/[math, strformat] +import std/[math, strformat, strutils] type Complex*[T: SomeFloat] = object diff --git a/tests/stdlib/tcomplex.nim b/tests/stdlib/tcomplex.nim index ca83314b94..02023f696b 100644 --- a/tests/stdlib/tcomplex.nim +++ b/tests/stdlib/tcomplex.nim @@ -2,7 +2,7 @@ discard """ matrix: "--mm:refc; --mm:orc" """ -import std/[complex, math] +import std/[complex, math, strformat, formatfloat] import std/assertions proc `=~`[T](x, y: Complex[T]): bool = @@ -113,3 +113,7 @@ doAssert 123.0.im + 456.0 == complex64(456, 123) let localA = complex(0.1'f32) doAssert localA.im is float32 + +block: # bug #24666 + let z = complex64(1, 2) + doAssert fmt"{z}" == "(1.0, 2.0)"