diff --git a/compiler/cgen.nim b/compiler/cgen.nim index 598b77ecdb..b1893cabfb 100644 --- a/compiler/cgen.nim +++ b/compiler/cgen.nim @@ -1507,7 +1507,7 @@ proc genProcNoForward(m: BModule, prc: PSym) = #if prc.loc.k == locNone: # mangle the inline proc based on the module where it is defined - # not on the first module that uses it - if optCompress in m.config.globalOptions: + if m.module.itemId.module != prc.itemId.module and optCompress in m.config.globalOptions: let prcCopy = copyInlineProc(prc, m.idgen) fillProcLoc(m, prcCopy.ast[namePos]) genProcPrototype(m, prcCopy) diff --git a/compiler/inliner.nim b/compiler/inliner.nim index becf88007a..a8f032bccc 100644 --- a/compiler/inliner.nim +++ b/compiler/inliner.nim @@ -1,4 +1,18 @@ +proc copySymdef(n: PNode; locals: var Table[int, PSym]; idgen: IdGenerator; owner: PSym): PNode = + case n.kind + of nkEmpty..pred(nkSym), succ(nkSym)..nkNilLit: + result = n + of nkSym: + let oldSym = n.sym + let newSym = copySym(oldSym, idgen) + setOwner(newSym, owner) + locals[oldSym.id] = newSym + result = newSymNode(newSym, oldSym.info) + else: + result = shallowCopy(n) + for i in 0.. 0: result.typ.n.add copyNode(prc.typ.n[0]) + for i in 1..