bugfix: inline iterator do not mess up line information anymore
This commit is contained in:
parent
c7e54eba91
commit
1fa3a9dac2
2 changed files with 29 additions and 3 deletions
|
|
@ -133,13 +133,17 @@ proc transformSymAux(c: PTransf, n: PNode): PNode =
|
||||||
# simply exchange the symbol:
|
# simply exchange the symbol:
|
||||||
b = s.getBody
|
b = s.getBody
|
||||||
if b.kind != nkSym: internalError(n.info, "wrong AST for borrowed symbol")
|
if b.kind != nkSym: internalError(n.info, "wrong AST for borrowed symbol")
|
||||||
b = newSymNode(b.sym)
|
b = newSymNode(b.sym, n.info)
|
||||||
b.info = n.info
|
|
||||||
else:
|
else:
|
||||||
b = n
|
b = n
|
||||||
while tc != nil:
|
while tc != nil:
|
||||||
result = idNodeTableGet(tc.mapping, b.sym)
|
result = idNodeTableGet(tc.mapping, b.sym)
|
||||||
if result != nil: return
|
if result != nil:
|
||||||
|
# this slightly convoluted way ensures the line info stays correct:
|
||||||
|
if result.kind == nkSym:
|
||||||
|
result = copyNode(result)
|
||||||
|
result.info = n.info
|
||||||
|
return
|
||||||
tc = tc.next
|
tc = tc.next
|
||||||
result = b
|
result = b
|
||||||
|
|
||||||
|
|
|
||||||
22
tests/errmsgs/tproper_stacktrace2.nim
Normal file
22
tests/errmsgs/tproper_stacktrace2.nim
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
discard """
|
||||||
|
outputsub: '''tproper_stacktrace2.nim(20) main'''
|
||||||
|
exitcode: 1
|
||||||
|
"""
|
||||||
|
|
||||||
|
proc returnsNil(): string = return nil
|
||||||
|
|
||||||
|
iterator fields*(a, b: int): int =
|
||||||
|
if a == b:
|
||||||
|
for f in a..b:
|
||||||
|
yield f
|
||||||
|
else:
|
||||||
|
for f in a..b:
|
||||||
|
yield f
|
||||||
|
|
||||||
|
proc main(): string =
|
||||||
|
result = ""
|
||||||
|
for i in fields(0, 1):
|
||||||
|
let x = returnsNil()
|
||||||
|
result &= "string literal " & $x
|
||||||
|
|
||||||
|
echo main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue