Files
Nim/tests/arc/t18977.nim
ringabout b5ee81fd23 fix #18977; disallow change branch of an object variant in ORC (#21526)
* fix #18977 disallow change branch of an object variant in ORC

* check errors for goto exception

* fixes conditions

* fixes tests

* add a test case for #18977
2023-03-16 16:06:26 +01:00

27 lines
350 B
Nim

discard """
matrix: "--mm:arc"
"""
type
E = enum
a, b, c, d
X = object
v: int
O = object
case kind: E
of a:
a: int
of {b, c}:
b: float
else:
d: X
proc `=destroy`(x: var X) =
echo "x destroyed"
var o = O(kind: d, d: X(v: 12345))
doAssert o.d.v == 12345
doAssertRaises(FieldDefect):
o.kind = a