mirror of
https://github.com/nim-lang/Nim.git
synced 2025-12-28 17:04:41 +00:00
fixes #1323
This commit is contained in:
@@ -1244,12 +1244,15 @@ proc genRdVar(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags) =
|
||||
# see tests/t99bott for an example that triggers it:
|
||||
cannotEval(n)
|
||||
|
||||
template needsRegLoad(): expr =
|
||||
gfAddrOf notin flags and fitsRegister(n.typ.skipTypes({tyVar}))
|
||||
|
||||
proc genArrAccess2(c: PCtx; n: PNode; dest: var TDest; opc: TOpcode;
|
||||
flags: TGenFlags) =
|
||||
let a = c.genx(n.sons[0], flags)
|
||||
let b = c.genIndex(n.sons[1], n.sons[0].typ)
|
||||
if dest < 0: dest = c.getTemp(n.typ)
|
||||
if gfAddrOf notin flags and fitsRegister(n.typ):
|
||||
if needsRegLoad():
|
||||
var cc = c.getTemp(n.typ)
|
||||
c.gABC(n, opc, cc, a, b)
|
||||
c.gABC(n, opcNodeToReg, dest, cc)
|
||||
@@ -1265,7 +1268,7 @@ proc genObjAccess(c: PCtx; n: PNode; dest: var TDest; flags: TGenFlags) =
|
||||
let a = c.genx(n.sons[0], flags)
|
||||
let b = genField(n.sons[1])
|
||||
if dest < 0: dest = c.getTemp(n.typ)
|
||||
if gfAddrOf notin flags and fitsRegister(n.typ.skipTypes({tyVar})):
|
||||
if needsRegLoad():
|
||||
var cc = c.getTemp(n.typ)
|
||||
c.gABC(n, opcLdObj, cc, a, b)
|
||||
c.gABC(n, opcNodeToReg, dest, cc)
|
||||
@@ -1700,7 +1703,7 @@ proc genProc(c: PCtx; s: PSym): int =
|
||||
c.gABC(body, opcEof, eofInstr.regA)
|
||||
c.optimizeJumps(result)
|
||||
s.offset = c.prc.maxSlots
|
||||
#if s.name.s == "get_data":
|
||||
#if s.name.s == "calc":
|
||||
# echo renderTree(body)
|
||||
# c.echoCode(result)
|
||||
c.prc = oldPrc
|
||||
|
||||
@@ -11,7 +11,8 @@ true
|
||||
true
|
||||
nil'''
|
||||
|
||||
output: '''test'''
|
||||
output: '''test
|
||||
2'''
|
||||
"""
|
||||
|
||||
type
|
||||
@@ -78,3 +79,12 @@ macro testnilcheck(): stmt =
|
||||
discard nilcheck()
|
||||
|
||||
testnilcheck()
|
||||
|
||||
# bug #1323
|
||||
|
||||
proc calc(): array[1, int] =
|
||||
result[0].inc()
|
||||
result[0].inc()
|
||||
|
||||
const c = calc()
|
||||
echo c[0]
|
||||
2
todo.txt
2
todo.txt
@@ -7,13 +7,13 @@ version 0.9.6
|
||||
Concurrency
|
||||
-----------
|
||||
|
||||
- 'gcsafe' inferrence needs to be fixed
|
||||
- the disjoint checker needs to deal with 'a = spawn f(); g = spawn f()'
|
||||
- implement 'deepCopy' builtin
|
||||
- implement 'foo[1..4] = spawn(f[4..7])'
|
||||
- support for exception propagation
|
||||
- Minor: The copying of the 'ref Promise' into the thead local storage only
|
||||
happens to work due to the write barrier's implementation
|
||||
- 'gcsafe' inferrence needs to be fixed
|
||||
- implement lock levels --> first without the more complex race avoidance
|
||||
- document the new 'spawn' and 'parallel' statements
|
||||
|
||||
|
||||
Reference in New Issue
Block a user