* fix nim js cmp fails at CT * follow up #17486 * test more branches * better
This commit is contained in:
parent
c015ecdc37
commit
13a2030014
1 changed files with 45 additions and 0 deletions
45
tests/iter/t16076.nim
Normal file
45
tests/iter/t16076.nim
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
discard """
|
||||||
|
targets: "c js"
|
||||||
|
"""
|
||||||
|
|
||||||
|
proc main() =
|
||||||
|
block: # bug #17485
|
||||||
|
type
|
||||||
|
O = ref object
|
||||||
|
i: int
|
||||||
|
|
||||||
|
iterator t(o: O): int =
|
||||||
|
if o != nil:
|
||||||
|
yield o.i
|
||||||
|
yield 0
|
||||||
|
|
||||||
|
proc m =
|
||||||
|
var data = ""
|
||||||
|
for i in t(nil):
|
||||||
|
data.addInt i
|
||||||
|
|
||||||
|
doAssert data == "0"
|
||||||
|
|
||||||
|
m()
|
||||||
|
|
||||||
|
|
||||||
|
block: # bug #16076
|
||||||
|
type
|
||||||
|
R = ref object
|
||||||
|
z: int
|
||||||
|
|
||||||
|
var data = ""
|
||||||
|
|
||||||
|
iterator foo(x: int; y: R = nil): int {.inline.} =
|
||||||
|
if y == nil:
|
||||||
|
yield x
|
||||||
|
else:
|
||||||
|
yield y.z
|
||||||
|
|
||||||
|
for b in foo(10):
|
||||||
|
data.addInt b
|
||||||
|
|
||||||
|
doAssert data == "10"
|
||||||
|
|
||||||
|
static: main()
|
||||||
|
main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue