Skip to content

Commit

Permalink
fix #15043 (#16441) [backport:1.4]
Browse files Browse the repository at this point in the history
* fix #15043

* Trigger build
  • Loading branch information
cooldome authored Dec 27, 2020
1 parent e718a4a commit fbc8a40
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
12 changes: 7 additions & 5 deletions compiler/lambdalifting.nim
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,11 @@ proc liftingHarmful(conf: ConfigRef; owner: PSym): bool {.inline.} =
result = conf.backend == backendJs and not isCompileTime

proc createTypeBoundOpsLL(g: ModuleGraph; refType: PType; info: TLineInfo; idgen: IdGenerator; owner: PSym) =
createTypeBoundOps(g, nil, refType.lastSon, info, idgen)
createTypeBoundOps(g, nil, refType, info, idgen)
if tfHasAsgn in refType.flags or optSeqDestructors in g.config.globalOptions:
owner.flags.incl sfInjectDestructors
if owner.kind != skMacro:
createTypeBoundOps(g, nil, refType.lastSon, info, idgen)
createTypeBoundOps(g, nil, refType, info, idgen)
if tfHasAsgn in refType.flags or optSeqDestructors in g.config.globalOptions:
owner.flags.incl sfInjectDestructors

proc liftIterSym*(g: ModuleGraph; n: PNode; idgen: IdGenerator; owner: PSym): PNode =
# transforms (iter) to (let env = newClosure[iter](); (iter, env))
Expand Down Expand Up @@ -613,7 +614,8 @@ proc rawClosureCreation(owner: PSym;
let fieldAccess = indirectAccess(env, local, env.info)
# add ``env.param = param``
result.add(newAsgnStmt(fieldAccess, newSymNode(local), env.info))
createTypeBoundOps(d.graph, nil, fieldAccess.typ, env.info, d.idgen)
if owner.kind != skMacro:
createTypeBoundOps(d.graph, nil, fieldAccess.typ, env.info, d.idgen)
if tfHasAsgn in fieldAccess.typ.flags or optSeqDestructors in d.graph.config.globalOptions:
owner.flags.incl sfInjectDestructors

Expand Down
16 changes: 16 additions & 0 deletions tests/arc/trepr.nim
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,19 @@ proc p2 =

discard repr p2


#####################################################################
# bug #15043

import macros

macro extract(): untyped =
result = newStmtList()
var x: seq[tuple[node: NimNode]]

proc test(n: NimNode) {.closure.} =
x.add (node: n)

test(parseExpr("discard"))

extract()

0 comments on commit fbc8a40

Please sign in to comment.