parent
3f1a85b7f0
commit
a87062393a
2 changed files with 24 additions and 2 deletions
|
|
@ -31,6 +31,7 @@ type
|
||||||
emptyNode: PNode
|
emptyNode: PNode
|
||||||
otherRead: PNode
|
otherRead: PNode
|
||||||
inLoop: int
|
inLoop: int
|
||||||
|
declaredVars: IntSet # variables we already moved to the top level
|
||||||
uninit: IntSet # set of uninit'ed vars
|
uninit: IntSet # set of uninit'ed vars
|
||||||
uninitComputed: bool
|
uninitComputed: bool
|
||||||
|
|
||||||
|
|
@ -345,7 +346,7 @@ proc passCopyToSink(n: PNode; c: var Con): PNode =
|
||||||
var m = genCopy(c, tmp, n)
|
var m = genCopy(c, tmp, n)
|
||||||
m.add p(n, c, normal)
|
m.add p(n, c, normal)
|
||||||
result.add m
|
result.add m
|
||||||
if isLValue(n) and not isClosureEnv(n):
|
if isLValue(n) and not isClosureEnv(n) and n.typ.skipTypes(abstractInst).kind != tyRef:
|
||||||
message(c.graph.config, n.info, hintPerformance,
|
message(c.graph.config, n.info, hintPerformance,
|
||||||
("passing '$1' to a sink parameter introduces an implicit copy; " &
|
("passing '$1' to a sink parameter introduces an implicit copy; " &
|
||||||
"use 'move($1)' to prevent it") % $n)
|
"use 'move($1)' to prevent it") % $n)
|
||||||
|
|
@ -589,6 +590,7 @@ proc p(n: PNode; c: var Con; mode: ProcessMode): PNode =
|
||||||
if v.kind == nkSym:
|
if v.kind == nkSym:
|
||||||
if sfCompileTime in v.sym.flags: continue
|
if sfCompileTime in v.sym.flags: continue
|
||||||
# move the variable declaration to the top of the frame:
|
# move the variable declaration to the top of the frame:
|
||||||
|
if not containsOrIncl(c.declaredVars, v.sym.id):
|
||||||
c.addTopVar v
|
c.addTopVar v
|
||||||
# make sure it's destroyed at the end of the proc:
|
# make sure it's destroyed at the end of the proc:
|
||||||
if not isUnpackedTuple(v) and sfThread notin v.sym.flags:
|
if not isUnpackedTuple(v) and sfThread notin v.sym.flags:
|
||||||
|
|
|
||||||
20
tests/arc/tstrformat.nim
Normal file
20
tests/arc/tstrformat.nim
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
discard """
|
||||||
|
output: '''verstuff'''
|
||||||
|
cmd: "nim c --gc:arc $file"
|
||||||
|
"""
|
||||||
|
|
||||||
|
# bug #13622
|
||||||
|
|
||||||
|
import strformat
|
||||||
|
|
||||||
|
template necho*(args: string) {.dirty.} =
|
||||||
|
if getCurrentException() != nil:
|
||||||
|
echo args
|
||||||
|
else:
|
||||||
|
stdout.writeLine(args)
|
||||||
|
|
||||||
|
proc main(cond: bool; arg: string) =
|
||||||
|
if cond:
|
||||||
|
necho &"ver{arg}\n"
|
||||||
|
|
||||||
|
main(true, "stuff")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue