Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #13269 #13344

Merged
merged 1 commit into from
Feb 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions compiler/liftdestructors.nim
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ proc fillBodyObj(c: var TLiftCtx; n, body, x, y: PNode; enforceDefaultOp: bool)
# XXX This is only correct for 'attachedSink'!
var localEnforceDefaultOp = enforceDefaultOp
if c.kind == attachedSink:
## the value needs to be destroyed before we assign the selector
## or the value is lost
# the value needs to be destroyed before we assign the selector
# or the value is lost
let prevKind = c.kind
c.kind = attachedDestructor
fillBodyObj(c, n, body, x, y, enforceDefaultOp = false)
Expand Down Expand Up @@ -704,7 +704,10 @@ proc fillBody(c: var TLiftCtx; t: PType; body, x, y: PNode) =
defaultOp(c, t, body, x, y)
of tyObject:
if not considerUserDefinedOp(c, t, body, x, y):
fillBodyObjT(c, t, body, x, y)
if c.kind in {attachedAsgn, attachedSink} and t.sym != nil and sfImportc in t.sym.flags:
body.add newAsgnStmt(x, y)
else:
fillBodyObjT(c, t, body, x, y)
of tyDistinct:
if not considerUserDefinedOp(c, t, body, x, y):
fillBody(c, t[0], body, x, y)
Expand Down
14 changes: 14 additions & 0 deletions tests/arc/timportedobj.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
discard """
cmd: "nim c --gc:arc $file"
action: "compile"
"""

# bug #13269

import posix
proc foo*() =
var last = newSeq[Stat]()
var next = last
for i in 0..3:
last = next
foo()