Skip to content

Commit

Permalink
fixes nim-lang#12670 [backport] (nim-lang#12693)
Browse files Browse the repository at this point in the history
(cherry picked from commit 78e02d1)
  • Loading branch information
Araq authored and narimiran committed Nov 21, 2019
1 parent aaf06db commit 7d444ff
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/vm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,8 @@ template handleJmpBack() {.dirty.} =
dec(c.loopIterations)

proc recSetFlagIsRef(arg: PNode) =
arg.flags.incl(nfIsRef)
if arg.kind notin {nkStrLit..nkTripleStrLit}:
arg.flags.incl(nfIsRef)
for i in 0 ..< arg.safeLen:
arg.sons[i].recSetFlagIsRef

Expand Down
20 changes: 20 additions & 0 deletions tests/vm/tmisc_vm.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ main:end
(width: 0, height: 0, path: "")
@[(width: 0, height: 0, path: ""), (width: 0, height: 0, path: "")]
Done!
foo4
foo4
foo4
'''
"""

Expand Down Expand Up @@ -214,3 +217,20 @@ static:
someTransform(state)

doAssert state[1] == 13087528040916209671'u64

import macros
# bug #12670

macro fooImpl(arg: untyped) =
result = quote do:
`arg`

proc foo(): string {.compileTime.} =
fooImpl:
result = "foo"
result.addInt 4

static:
echo foo()
echo foo()
echo foo()

0 comments on commit 7d444ff

Please sign in to comment.