diff options
-rw-r--r-- | compiler/cgen.nim | 7 | ||||
-rw-r--r-- | compiler/cgmeth.nim | 6 | ||||
-rw-r--r-- | compiler/ic/cbackend.nim | 5 | ||||
-rw-r--r-- | compiler/pipelines.nim | 14 | ||||
-rw-r--r-- | tests/arc/tarcmisc.nim | 6 |
5 files changed, 26 insertions, 12 deletions
diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 61bdab858..64c48cf07 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1099,7 +1099,7 @@ proc genProcBody(p: BProc; procBody: PNode) = proc isNoReturn(m: BModule; s: PSym): bool {.inline.} = sfNoReturn in s.flags and m.config.exc != excGoto -proc genProcAux(m: BModule, prc: PSym) = +proc genProcAux*(m: BModule, prc: PSym) = var p = newProc(prc, m) var header = newRopeAppender() genProcHeader(m, prc, header) @@ -2107,7 +2107,7 @@ proc updateCachedModule(m: BModule) = cf.flags = {CfileFlag.Cached} addFileToCompile(m.config, cf) -proc finalCodegenActions*(graph: ModuleGraph; m: BModule; n: PNode) = +proc finalCodegenActions*(graph: ModuleGraph; m: BModule; n: PNode): PNode = ## Also called from IC. if sfMainModule in m.module.flags: # phase ordering problem here: We need to announce this @@ -2153,8 +2153,7 @@ proc finalCodegenActions*(graph: ModuleGraph; m: BModule; n: PNode) = if m.g.forwardedProcs.len == 0: incl m.flags, objHasKidsValid - let disp = generateMethodDispatchers(graph, m.idgen) - for x in disp: genProcAux(m, x.sym) + result = generateMethodDispatchers(graph, m.idgen) let mm = m m.g.modulesClosed.add mm diff --git a/compiler/cgmeth.nim b/compiler/cgmeth.nim index 1ea34f17b..1711c5f9a 100644 --- a/compiler/cgmeth.nim +++ b/compiler/cgmeth.nim @@ -11,7 +11,7 @@ import intsets, options, ast, msgs, idents, renderer, types, magicsys, - sempass2, modulegraphs, lineinfos, liftdestructors + sempass2, modulegraphs, lineinfos when defined(nimPreviewSlimSystem): import std/assertions @@ -254,10 +254,6 @@ proc genDispatcher(g: ModuleGraph; methods: seq[PSym], relevantCols: IntSet; idg curr.typ[col], false, g.config) var ret: PNode if retTyp != nil: - createTypeBoundOps(g, nil, retTyp, base.info, idgen) - if tfHasAsgn in result.typ.flags or optSeqDestructors in g.config.globalOptions: - base.flags.incl sfInjectDestructors - var a = newNodeI(nkFastAsgn, base.info) a.add newSymNode(base.ast[resultPos].sym) a.add call diff --git a/compiler/ic/cbackend.nim b/compiler/ic/cbackend.nim index 815078a36..21f69e485 100644 --- a/compiler/ic/cbackend.nim +++ b/compiler/ic/cbackend.nim @@ -50,7 +50,10 @@ proc generateCodeForModule(g: ModuleGraph; m: var LoadedModule; alive: var Alive let n = unpackTree(g, m.module.position, m.fromDisk.topLevel, p) cgen.genTopLevelStmt(bmod, n) - finalCodegenActions(g, bmod, newNodeI(nkStmtList, m.module.info)) + let disps = finalCodegenActions(g, bmod, newNodeI(nkStmtList, m.module.info)) + if disps != nil: + for disp in disps: + genProcAux(bmod, disp.sym) m.fromDisk.backendFlags = cgen.whichInitProcs(bmod) proc replayTypeInfo(g: ModuleGraph; m: var LoadedModule; origin: FileIndex) = diff --git a/compiler/pipelines.nim b/compiler/pipelines.nim index 90f6de5c0..4e574e56b 100644 --- a/compiler/pipelines.nim +++ b/compiler/pipelines.nim @@ -1,6 +1,7 @@ import sem, cgen, modulegraphs, ast, llstream, parser, msgs, lineinfos, reorder, options, semdata, cgendata, modules, pathutils, - packages, syntaxes, depends, vm, pragmas, idents, lookups, wordrecg + packages, syntaxes, depends, vm, pragmas, idents, lookups, wordrecg, + liftdestructors import pipelineutils @@ -176,7 +177,16 @@ proc processPipelineModule*(graph: ModuleGraph; module: PSym; idgen: IdGenerator case graph.pipelinePass of CgenPass: if bModule != nil: - finalCodegenActions(graph, BModule(bModule), finalNode) + let disps = finalCodegenActions(graph, BModule(bModule), finalNode) + if disps != nil: + let ctx = preparePContext(graph, module, idgen) + for disp in disps: + let retTyp = disp.sym.typ[0] + if retTyp != nil: + # todo properly semcheck the code of dispatcher? + createTypeBoundOps(graph, ctx, retTyp, disp.info, idgen) + genProcAux(BModule(bModule), disp.sym) + discard closePContext(graph, ctx, nil) of JSgenPass: when not defined(leanCompiler): discard finalJSCodeGen(graph, bModule, finalNode) diff --git a/tests/arc/tarcmisc.nim b/tests/arc/tarcmisc.nim index b08669774..1404f54a1 100644 --- a/tests/arc/tarcmisc.nim +++ b/tests/arc/tarcmisc.nim @@ -600,6 +600,7 @@ block: # bug #19857 import std/options +# bug #21592 type Event* = object code*: string @@ -608,3 +609,8 @@ type App* = ref object of RootObj method process*(self: App): Option[Event] {.base.} = raise Exception.new_exception("not impl") + +# bug #21617 +type Test2 = ref object of RootObj + +method bug(t: Test2): seq[float] {.base.} = discard |