* fix nim js cmp fails at CT

* follow up #17486

* test more branches

* better
This commit is contained in:
flywind
2021-03-24 15:49:05 +08:00
committed by GitHub
parent c015ecdc37
commit 13a2030014

45
tests/iter/t16076.nim Normal file
View 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()