diff options
-rw-r--r-- | compiler/vmgen.nim | 9 | ||||
-rw-r--r-- | tests/macros/tbugs.nim (renamed from tests/macros/tbug1149.nim) | 12 | ||||
-rw-r--r-- | todo.txt | 2 |
3 files changed, 18 insertions, 5 deletions
diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index b04e60549..c1ec637dd 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -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 diff --git a/tests/macros/tbug1149.nim b/tests/macros/tbugs.nim index 3318fbfd8..3db851dd1 100644 --- a/tests/macros/tbug1149.nim +++ b/tests/macros/tbugs.nim @@ -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] diff --git a/todo.txt b/todo.txt index 8a1caee3b..8450cbbc3 100644 --- a/todo.txt +++ b/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 |