diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-10-12 11:32:29 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-10-12 11:32:29 +0200 |
commit | ec253ada72a50f5fdca5c86fdf01b7099b1803aa (patch) | |
tree | dc1b5572fed974a57b15bc0736e3cdd33faf7193 /compiler/semstmts.nim | |
parent | 078e78d2087777ad14be152a5d2b7e72a1884a31 (diff) | |
download | Nim-ec253ada72a50f5fdca5c86fdf01b7099b1803aa.tar.gz |
initial version of the new untested destructor pass
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r-- | compiler/semstmts.nim | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index a83de6d27..70e258bac 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -399,7 +399,7 @@ proc addToVarSection(c: PContext; result: var PNode; orig, identDefs: PNode) = # in order for this transformation to be correct. let L = identDefs.len let value = identDefs[L-1] - if value.typ != nil and tfHasAsgn in value.typ.flags: + if value.typ != nil and tfHasAsgn in value.typ.flags and c.p.owner.kind != skFunc: # the spec says we need to rewrite 'var x = T()' to 'var x: T; x = T()': identDefs.sons[L-1] = emptyNode if result.kind != nkStmtList: @@ -1303,7 +1303,7 @@ proc semOverride(c: PContext, s: PSym, n: PNode) = localError(n.info, errGenerated, "signature for 'deepCopy' must be proc[T: ptr|ref](x: T): T") incl(s.flags, sfUsed) - of "=": + of "=", "=sink": if s.magic == mAsgn: return incl(s.flags, sfUsed) let t = s.typ @@ -1321,14 +1321,15 @@ proc semOverride(c: PContext, s: PSym, n: PNode) = objB = objB.sons[0] else: break if obj.kind in {tyObject, tyDistinct} and sameType(obj, objB): - if obj.assignment.isNil: - obj.assignment = s + let opr = if s.name.s == "=": addr(obj.assignment) else: addr(obj.sink) + if opr[].isNil: + opr[] = s else: localError(n.info, errGenerated, - "cannot bind another '=' to: " & typeToString(obj)) + "cannot bind another '" & s.name.s & "' to: " & typeToString(obj)) return localError(n.info, errGenerated, - "signature for '=' must be proc[T: object](x: var T; y: T)") + "signature for '" & s.name.s & "' must be proc[T: object](x: var T; y: T)") else: if sfOverriden in s.flags: localError(n.info, errGenerated, |