implemented strictCaseObjects (#20608)
* implemented strictCaseObjects * changelog update
This commit is contained in:
parent
4aa67ad7fd
commit
76763f51aa
6 changed files with 80 additions and 8 deletions
27
tests/effects/tstrict_caseobjects.nim
Normal file
27
tests/effects/tstrict_caseobjects.nim
Normal 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"
|
||||
Loading…
Add table
Add a link
Reference in a new issue