mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-09 14:32:53 +00:00
This reverts commit 3ce38f2959.
This commit is contained in:
@@ -2420,20 +2420,6 @@ proc addHcrInitGuards(p: BProc, n: PNode, inInitGuard: var bool, init: var IfBui
|
||||
|
||||
genStmts(p, n)
|
||||
|
||||
proc handleProcGlobals(m: BModule) =
|
||||
var procGlobals: seq[PNode] = move m.g.graph.procGlobals
|
||||
|
||||
for i in 0..<procGlobals.len:
|
||||
var stmts = newBuilder("")
|
||||
|
||||
# fixes recursive calls #24997
|
||||
swap stmts, m.preInitProc.s(cpsStmts)
|
||||
genStmts(m.preInitProc, procGlobals[i])
|
||||
swap stmts, m.preInitProc.s(cpsStmts)
|
||||
|
||||
handleProcGlobals(m)
|
||||
m.preInitProc.s(cpsStmts).add stmts.extract()
|
||||
|
||||
proc genTopLevelStmt*(m: BModule; n: PNode) =
|
||||
## Also called from `ic/cbackend.nim`.
|
||||
if pipelineutils.skipCodegen(m.config, n): return
|
||||
@@ -2449,7 +2435,13 @@ proc genTopLevelStmt*(m: BModule; n: PNode) =
|
||||
else:
|
||||
genProcBody(m.initProc, transformedN)
|
||||
|
||||
handleProcGlobals(m)
|
||||
var procGloals = move m.g.graph.procGlobals
|
||||
while true:
|
||||
if procGloals.len == 0:
|
||||
procGloals = move m.g.graph.procGlobals
|
||||
if procGloals.len == 0:
|
||||
break
|
||||
genStmts(m.preInitProc, procGloals.pop())
|
||||
|
||||
proc shouldRecompile(m: BModule; code: Rope, cfile: Cfile): bool =
|
||||
if optForceFullMake notin m.config.globalOptions:
|
||||
|
||||
@@ -41,17 +41,3 @@ block: # bug #24981
|
||||
type Foo = object
|
||||
i: int
|
||||
m(Foo)
|
||||
|
||||
block: # bug #24997
|
||||
type R = ref object
|
||||
type B = object
|
||||
j: int
|
||||
proc y(T: type): R
|
||||
proc u(T: type): R =
|
||||
let res {.global.} = y(T)
|
||||
res
|
||||
proc y(T: type): R =
|
||||
when T is object:
|
||||
doAssert not isNil(u(typeof(B.j)))
|
||||
R()
|
||||
discard u(B)
|
||||
|
||||
Reference in New Issue
Block a user