diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2018-12-15 13:54:41 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2018-12-15 13:54:41 +0100 |
commit | e3a668a33baaf9d89b287827eaab3fa1cdfec877 (patch) | |
tree | bf374e97230a61d036176638bcaf7798d70985d3 /compiler/semstmts.nim | |
parent | 446f911a173a595648fa444c83d931193198eeb6 (diff) | |
download | Nim-e3a668a33baaf9d89b287827eaab3fa1cdfec877.tar.gz |
--gc:destructors: baby steps
Diffstat (limited to 'compiler/semstmts.nim')
-rw-r--r-- | compiler/semstmts.nim | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 2d98d84e1..277fbd75f 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -1427,6 +1427,12 @@ proc maybeAddResult(c: PContext, s: PSym, n: PNode) = addResult(c, s.typ.sons[0], n.info, s.kind) addResultNode(c, n) +proc canonType(c: PContext, t: PType): PType = + if t.kind == tySequence: + result = c.graph.sysTypes[tySequence] + else: + result = t + proc semOverride(c: PContext, s: PSym, n: PNode) = case s.name.s.normalize of "=destroy": @@ -1440,6 +1446,7 @@ proc semOverride(c: PContext, s: PSym, n: PNode) = elif obj.kind == tyGenericInvocation: obj = obj.sons[0] else: break if obj.kind in {tyObject, tyDistinct, tySequence, tyString}: + obj = canonType(c, obj) if obj.destructor.isNil: obj.destructor = s else: @@ -1491,6 +1498,8 @@ proc semOverride(c: PContext, s: PSym, n: PNode) = objB = objB.sons[0] else: break if obj.kind in {tyObject, tyDistinct, tySequence, tyString} and sameType(obj, objB): + # attach these ops to the canonical tySequence + obj = canonType(c, obj) let opr = if s.name.s == "=": addr(obj.assignment) else: addr(obj.sink) if opr[].isNil: opr[] = s |