mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
fixes #23139
(cherry picked from commit 3dee1a3e4c)
This commit is contained in:
@@ -98,7 +98,7 @@ proc repr*(p: proc | iterator {.closure.}): string =
|
||||
## repr of a proc as its address
|
||||
repr(cast[ptr pointer](unsafeAddr p)[])
|
||||
|
||||
template repr*[T: distinct|range](x: T): string =
|
||||
template repr*[T: distinct|(range and not enum)](x: T): string =
|
||||
when T is range: # add a branch to handle range
|
||||
repr(rangeBase(typeof(x))(x))
|
||||
elif T is distinct:
|
||||
|
||||
@@ -66,3 +66,8 @@ var x: array[8, CTBool[Ct[uint32]]]
|
||||
x[0] = (CTBool[Ct[uint32]])(1)
|
||||
echo x.repr, " ", typeof(x[0])
|
||||
|
||||
block: # bug #23139
|
||||
type Foo = enum a, b
|
||||
|
||||
var x: range[a..b]
|
||||
doAssert (repr x) == "a"
|
||||
|
||||
Reference in New Issue
Block a user