fixes #20715; range[a..b] inside object variant fails (#20716)

* fixes #20715; range[a..b] inside object variant fails

* step one fix

* better fix

* fixes private fields

* mistake
This commit is contained in:
ringabout 2022-11-01 01:42:45 +08:00 • committed by GitHub
commit 39f925b95d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 5 deletions

View file

@ -426,6 +426,36 @@ template main {.dirty.} =
let x = default(A)
doAssert $x == "(d: Uninitialized DateTime)"
block: # bug #20715
block:
type
Foo = enum
A
B
Bar = object
case foo: Foo
of A:
t: range[-1..2]
else: discard
var d = default(Bar)
doAssert d.t == -1
block:
type
Foo = enum
A
B
Bar = object
case foo: Foo
of A:
t: range[0..2]
else: discard
var d = default(Bar)
doAssert d.t == 0
static: main()
main()