diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2020-10-08 23:56:09 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-09 08:56:09 +0200 |
commit | 8fb57d74515348d04dcd8c132e5e3787be80b577 (patch) | |
tree | 07c42bc34c3997e9251384c8bf64bcbd5a6b4ce2 | |
parent | 91ce4515c87c084ade6b2b74ebfc2e19e25b5261 (diff) | |
download | Nim-8fb57d74515348d04dcd8c132e5e3787be80b577.tar.gz |
close #13081 (#15529)
* close #13081 * fixup
-rw-r--r-- | tests/vm/tvmmisc.nim | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/vm/tvmmisc.nim b/tests/vm/tvmmisc.nim index 20adb5b8f..7da1c6743 100644 --- a/tests/vm/tvmmisc.nim +++ b/tests/vm/tvmmisc.nim @@ -178,3 +178,34 @@ const static: doAssert ctor doAssert ctand + +block: # bug #13081 + type Kind = enum + k0, k1, k2, k3 + + type Foo = object + x0: float + case kind: Kind + of k0: discard + of k1: x1: int + of k2: x2: string + of k3: x3: string + + const j1 = Foo(x0: 1.2, kind: k1, x1: 12) + const j2 = Foo(x0: 1.3, kind: k2, x2: "abc") + const j3 = Foo(x0: 1.3, kind: k3, x3: "abc2") + static: + doAssert $j1 == "(x0: 1.2, kind: k1, x1: 12)" + doAssert $j2 == """(x0: 1.3, kind: k2, x2: "abc")""" + doAssert $j3 == """(x0: 1.3, kind: k3, x3: "abc2")""" + doAssert $j1 == "(x0: 1.2, kind: k1, x1: 12)" + doAssert $j2 == """(x0: 1.3, kind: k2, x2: "abc")""" + doAssert $j3 == """(x0: 1.3, kind: k3, x3: "abc2")""" + + when false: + # BUG: this doesn't work yet + # Error: unhandled exception: 'sons' is not accessible using discriminant 'kind' of type 'TNode' [FieldDefect] + discard j1.x1 + static: + # ditto + discard j1.x1 |