mirror of
https://github.com/nim-lang/Nim.git
synced 2026-06-08 21:04:20 +00:00
Fix for newStringOfCap in VM (#7901)
This commit is contained in:
committed by
Andreas Rumpf
parent
59ba1e77af
commit
440212a154
@@ -844,7 +844,8 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
|
||||
of mNewStringOfCap:
|
||||
# we ignore the 'cap' argument and translate it as 'newString(0)'.
|
||||
# eval n.sons[1] for possible side effects:
|
||||
var tmp = c.genx(n.sons[1])
|
||||
c.freeTemp(c.genx(n.sons[1]))
|
||||
var tmp = c.getTemp(n.sons[1].typ)
|
||||
c.gABx(n, opcLdImmInt, tmp, 0)
|
||||
if dest < 0: dest = c.getTemp(n.typ)
|
||||
c.gABC(n, opcNewStr, dest, tmp)
|
||||
|
||||
@@ -82,3 +82,11 @@ block:
|
||||
|
||||
assert fileExists("MISSINGFILE") == false
|
||||
assert dirExists("MISSINGDIR") == false
|
||||
|
||||
# #7210
|
||||
block:
|
||||
static:
|
||||
proc f(size: int): int =
|
||||
var some = newStringOfCap(size)
|
||||
result = size
|
||||
doAssert f(4) == 4
|
||||
Reference in New Issue
Block a user