implemented strictCaseObjects (#20608)

* implemented strictCaseObjects

* changelog update
This commit is contained in:
Andreas Rumpf 2022-10-21 06:55:52 +02:00 • committed by GitHub
commit 76763f51aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 80 additions and 8 deletions

View file

@ -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"