diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2022-10-21 06:55:52 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-21 06:55:52 +0200 |
commit | 76763f51aa119e71b00200142292acf5f1fdc69c (patch) | |
tree | c30b7c3c685d32cfa2c2dd79757e57204a85ab0c /tests/effects/tstrict_caseobjects.nim | |
parent | 4aa67ad7fd3179bd46fbeb793c3c71d14d9021a0 (diff) | |
download | Nim-76763f51aa119e71b00200142292acf5f1fdc69c.tar.gz |
implemented strictCaseObjects (#20608)
* implemented strictCaseObjects * changelog update
Diffstat (limited to 'tests/effects/tstrict_caseobjects.nim')
-rw-r--r-- | tests/effects/tstrict_caseobjects.nim | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/effects/tstrict_caseobjects.nim b/tests/effects/tstrict_caseobjects.nim new file mode 100644 index 000000000..e5e84f287 --- /dev/null +++ b/tests/effects/tstrict_caseobjects.nim @@ -0,0 +1,27 @@ +discard """ + errormsg: "field access outside of valid case branch: x.x" + line: 25 +""" + +{.experimental: "strictCaseObjects".} + +type + Foo = object + case b: bool + of false: + s: string + of true: + x: int + +var x = Foo(b: true, x: 4) +case x.b +of true: + echo x.x +of false: + echo "no" + +case x.b +of false: + echo x.x +of true: + echo "no" |