diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim index 73faac4955907..5cafc8d57849d 100644 --- a/tests/vm/tvmmisc.nim +++ b/tests/vm/tvmmisc.nim @@ -230,3 +230,34 @@ block: doAssert d == @[] doAssert e == @[] doAssert f == @[] + + + +block: # bug #10815 + block: + # this used to crash + type + Opcode = enum + iChar, iSet + Inst = object + case code: Opcode + of iChar: + c: char + of iSet: + cs: set[char] + + Patt = seq[Inst] + proc `$`(p: Patt): string = + discard + proc P(): Patt = + result.add Inst(code: iSet) + const a = P() + doAssert $a == "" + + block: + # probably used to crash + type CharSet {.union.} = object + cs: set[char] + vs: array[4, uint64] + const a = Charset(cs: {'a'..'z'}) + doAssert a.repr.len > 0