closes #12994; add testcase (#20511)

This commit is contained in:
ringabout 2022-10-08 00:27:17 +08:00 • committed by GitHub
commit a132f5502a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -572,3 +572,26 @@ block:
let y = x + 1 let y = x + 1
# Error: unhandled exception: value out of range: -8 notin 0 .. 65535 [RangeDefect] # Error: unhandled exception: value out of range: -8 notin 0 .. 65535 [RangeDefect]
echo y echo y
type Atom* = object
bar: int
proc main() = # bug #12994
var s: seq[Atom]
var atom: Atom
var checked = 0
for i in 0..<2:
atom.bar = 5
s.add atom
atom.reset
if i == 0:
checked += 1
doAssert $s == "@[(bar: 5)]"
else:
checked += 1
doAssert $s == "@[(bar: 5), (bar: 5)]"
doAssert checked == 2
static: main()
main()