diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 8c41fb370fc56..6d5f255670c1b 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2070,7 +2070,7 @@ proc genDispose(p: BProc; n: PNode) = proc genEnumToStr(p: BProc, e: PNode, d: var TLoc) = const ToStringProcSlot = -4 - let t = e[1].typ.skipTypes(abstractInst) + let t = e[1].typ.skipTypes(abstractInst+{tyRange}) var toStrProc: PSym = nil for idx, p in items(t.methods): if idx == ToStringProcSlot: diff --git a/tests/enum/tenum_no_rtti.nim b/tests/enum/tenum_no_rtti.nim new file mode 100644 index 0000000000000..2e5c74b356995 --- /dev/null +++ b/tests/enum/tenum_no_rtti.nim @@ -0,0 +1,12 @@ +discard """ + output: '''A +B''' + cmd: '''nim c --gc:arc $file''' +""" +type + Enum = enum A, B, C + EnumRange = range[A .. B] +proc test_a(x: Enum): string = $x +proc test_b(x: EnumRange): string = $x +echo test_a(A) +echo test_b(B)