diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2022-10-21 22:46:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-21 22:46:32 +0200 |
commit | 0faae4d5e29ea4eb55f3b53b1f01b91637f2c6c7 (patch) | |
tree | fb74d96c804ea36a75a4a58226dbd142f0c72d95 /tests/effects/tstrict_caseobjects.nim | |
parent | 3c12b72168d9fe9916f471fa17d2c24c52b33066 (diff) | |
download | Nim-0faae4d5e29ea4eb55f3b53b1f01b91637f2c6c7.tar.gz |
fixes a strict case object problem that has been reported on the forum (#20614)
Diffstat (limited to 'tests/effects/tstrict_caseobjects.nim')
-rw-r--r-- | tests/effects/tstrict_caseobjects.nim | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/effects/tstrict_caseobjects.nim b/tests/effects/tstrict_caseobjects.nim index e5e84f287..20bc810e0 100644 --- a/tests/effects/tstrict_caseobjects.nim +++ b/tests/effects/tstrict_caseobjects.nim @@ -1,11 +1,31 @@ discard """ errormsg: "field access outside of valid case branch: x.x" - line: 25 + line: 45 """ {.experimental: "strictCaseObjects".} type + NodeKind = enum + nkParent, + nkChild + + Node {.acyclic.} = ref object + case kind: NodeKind + of nkParent: + children: seq[Node] + of nkChild: + name: string + +let list = @[Node(kind: nkParent, children: @[]), Node(kind: nkChild, name: "hello")] +for node in list: + case node.kind + of nkChild: + echo $node.name # here this time there is a warning + else: discard + + +type Foo = object case b: bool of false: |