New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
iterator declaration zeros variable on ARC/ORC #19795
Comments
Or type Node = ref object
kind: Node
var n1 = Node()
var n2 = Node()
n2.kind = n1
proc foo =
echo cast[int](n1)
foo() |
It looks like dfa analysis cannot pass the scope boundry. Nim compiler thinks |
Yeah, the program splits into three parts. var
n1
n2
type
Node = ref object
kind: Node
n1 = Node()
n2 = Node()
`=sink`(n2.kind, n1)
wasMoved(n1) iterator iter(x: Node): Node =
discard var :tmpD_452984865
try:
echo [
:tmpD_452984865 = cast[int](n1)
:tmpD_452984865]
finally:
`=destroy`(:tmpD_452984865) |
It seems to caused by how the parser parses the top level statement: read everything until the next proc declaration etc. The top level statements splits into different parts. Dfa can only analyse them seperately. So dfa can only get partial infos regarding symbols. |
It breaks zero-functional tests. import zero_functional, options, lists
type
SimpleIter = ref object
items: seq[int]
proc initSimpleIter(): SimpleIter =
SimpleIter(items: @[1, 2, 3])
proc len(si: SimpleIter): int =
si.items.len()
iterator items(si: SimpleIter): int =
for i in 0..<len(si.items):
yield(si.items[i])
let si = initSimpleIter()
var d = si --> to(list)
d --> foreach(it = it * 2)
echo d --> to(seq)
let e: DoublyLinkedList[int] = d
discard(e)
echo d --> to(seq)
doAssert(d --> to(seq) == @[2, 4, 6])
proc (): auto =
{.push, hint[XDeclaredButNotUsed]: false.}
proc `__iterType__`(): auto =
var __itList__ = d.head
var idx = 0
while (
not (__itList__ == nil)):
let __it0 = __itList__.value
let _itListNext = __itList__.next
let __it1 = __it0
result = (__it0, __it1)
{.pop.}
var res`gensym87: seq[type(__iterType__()[1])]
result = zfInit(res`gensym87)
var __itList__ = d.head
var idx = 0
while (
not (__itList__ == nil)):
let __it0 = __itList__.value
let _itListNext = __itList__.next
let __it1 = __it0
zfAddItem(result, idx, __it1)
__itList__ = _itListNext
idx += 1() |
…m now parses the whole module at one time (#21379) * fixes #19795; remove parse pipeline * isScript * fixes nimscriptapi * don't touch reorder * check script * fixes tests * it seems implicit imports of system cause troubles * access the first child of `nkStmtList` * ignore comments * minor messages * perhaps increases hloLoopDetector * the module is a stmtList, which changes the errors * fixes nimdoc * fixes tlinter * fixes nim secret tests * fixes arc_misc * fixes nim secret tests again * safe; fixes one more test * GlobalError is the root cause too * fixes parsing errors * put emit types to the cfsForwardTypes section * fixes #11852; `{.push checks:off}` now works in procs * disable navigator * fixes nimdoc * add tests for JS * fixes nimsuggest
…ove parsing pipeline, Nim now parses the whole module at one time (nim-lang#21379) * fixes nim-lang#19795; remove parse pipeline * isScript * fixes nimscriptapi * don't touch reorder * check script * fixes tests * it seems implicit imports of system cause troubles * access the first child of `nkStmtList` * ignore comments * minor messages * perhaps increases hloLoopDetector * the module is a stmtList, which changes the errors * fixes nimdoc * fixes tlinter * fixes nim secret tests * fixes arc_misc * fixes nim secret tests again * safe; fixes one more test * GlobalError is the root cause too * fixes parsing errors * put emit types to the cfsForwardTypes section * fixes nim-lang#11852; `{.push checks:off}` now works in procs * disable navigator * fixes nimdoc * add tests for JS * fixes nimsuggest
…ove parsing pipeline, Nim now parses the whole module at one time (nim-lang#21379) * fixes nim-lang#19795; remove parse pipeline * isScript * fixes nimscriptapi * don't touch reorder * check script * fixes tests * it seems implicit imports of system cause troubles * access the first child of `nkStmtList` * ignore comments * minor messages * perhaps increases hloLoopDetector * the module is a stmtList, which changes the errors * fixes nimdoc * fixes tlinter * fixes nim secret tests * fixes arc_misc * fixes nim secret tests again * safe; fixes one more test * GlobalError is the root cause too * fixes parsing errors * put emit types to the cfsForwardTypes section * fixes nim-lang#11852; `{.push checks:off}` now works in procs * disable navigator * fixes nimdoc * add tests for JS * fixes nimsuggest
…ove parsing pipeline, Nim now parses the whole module at one time (nim-lang#21379) * fixes nim-lang#19795; remove parse pipeline * isScript * fixes nimscriptapi * don't touch reorder * check script * fixes tests * it seems implicit imports of system cause troubles * access the first child of `nkStmtList` * ignore comments * minor messages * perhaps increases hloLoopDetector * the module is a stmtList, which changes the errors * fixes nimdoc * fixes tlinter * fixes nim secret tests * fixes arc_misc * fixes nim secret tests again * safe; fixes one more test * GlobalError is the root cause too * fixes parsing errors * put emit types to the cfsForwardTypes section * fixes nim-lang#11852; `{.push checks:off}` now works in procs * disable navigator * fixes nimdoc * add tests for JS * fixes nimsuggest
Example
Current Output
Expected Output
some non-zero address
Additional Information
without --gc:orc or --gc:arc works fine
also if add
echo cast[int](n1)
before iterator declaration, works fineon 1.6.6 this bug also exists
The text was updated successfully, but these errors were encountered: