mirror of
https://github.com/nim-lang/Nim.git
synced 2026-02-11 22:08:54 +00:00
fix enumtostr crash for enum-range (#13035)
This commit is contained in:
committed by
Andreas Rumpf
parent
13c08f3ab4
commit
9474a818af
@@ -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:
|
||||
|
||||
12
tests/enum/tenum_no_rtti.nim
Normal file
12
tests/enum/tenum_no_rtti.nim
Normal file
@@ -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)
|
||||
Reference in New Issue
Block a user