diff --git a/lib/system/repr_v2.nim b/lib/system/repr_v2.nim index 3a40ac5ad7..fd2dd4c695 100644 --- a/lib/system/repr_v2.nim +++ b/lib/system/repr_v2.nim @@ -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: diff --git a/tests/metatype/tmetatype_various.nim b/tests/metatype/tmetatype_various.nim index be70f37a7d..68d41c4763 100644 --- a/tests/metatype/tmetatype_various.nim +++ b/tests/metatype/tmetatype_various.nim @@ -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"