Skip to content

Commit 6c34f62

Browse files
ringaboutnarimiran
authored andcommitted
fixes nim-lang#24666; Compilation error when formatting a complex number (nim-lang#24667)
fixes nim-lang#24666 ref nim-lang#22924 (cherry picked from commit 485b414)
1 parent 46e1322 commit 6c34f62

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/pure/complex.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ runnableExamples:
3333
{.push checks: off, line_dir: off, stack_trace: off, debugger: off.}
3434
# the user does not want to trace a part of the standard library!
3535

36-
import std/[math, strformat]
36+
import std/[math, strformat, strutils]
3737

3838
type
3939
Complex*[T: SomeFloat] = object

tests/stdlib/tcomplex.nim

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ discard """
22
matrix: "--mm:refc; --mm:orc"
33
"""
44

5-
import std/[complex, math]
5+
import std/[complex, math, strformat, formatfloat]
66
import std/assertions
77

88
proc `=~`[T](x, y: Complex[T]): bool =
@@ -113,3 +113,7 @@ doAssert 123.0.im + 456.0 == complex64(456, 123)
113113

114114
let localA = complex(0.1'f32)
115115
doAssert localA.im is float32
116+
117+
block: # bug #24666
118+
let z = complex64(1, 2)
119+
doAssert fmt"{z}" == "(1.0, 2.0)"

0 commit comments

Comments
 (0)