destructors: defensive programming against wrong generated destructor for string/seq
This commit is contained in:
parent
d20a273215
commit
5ffa9a8be6
2 changed files with 10 additions and 6 deletions
|
|
@ -480,7 +480,7 @@ proc processSwitch*(switch, arg: string, pass: TCmdLinePass, info: TLineInfo;
|
||||||
of "native", "gdb":
|
of "native", "gdb":
|
||||||
incl(conf.globalOptions, optCDebug)
|
incl(conf.globalOptions, optCDebug)
|
||||||
conf.options = conf.options + {optLineDir} - {optEndb}
|
conf.options = conf.options + {optLineDir} - {optEndb}
|
||||||
defineSymbol(conf.symbols, "nimTypeNames") # type names are used in gdb pretty printing
|
#defineSymbol(conf.symbols, "nimTypeNames") # type names are used in gdb pretty printing
|
||||||
undefSymbol(conf.symbols, "endb")
|
undefSymbol(conf.symbols, "endb")
|
||||||
else:
|
else:
|
||||||
localError(conf, info, "expected endb|gdb but found " & arg)
|
localError(conf, info, "expected endb|gdb but found " & arg)
|
||||||
|
|
|
||||||
|
|
@ -309,11 +309,15 @@ proc liftBody(c: PContext; typ: PType; kind: TTypeAttachedOp;
|
||||||
liftBodyAux(a, typ, body, newSymNode(dest).newDeref, newSymNode(src))
|
liftBodyAux(a, typ, body, newSymNode(dest).newDeref, newSymNode(src))
|
||||||
# recursion is handled explicitly, do not register the type based operation
|
# recursion is handled explicitly, do not register the type based operation
|
||||||
# before 'liftBodyAux':
|
# before 'liftBodyAux':
|
||||||
case kind
|
if c.config.selectedGC == gcDestructors and
|
||||||
of attachedAsgn: typ.assignment = result
|
typ.kind in {tySequence, tyString} and body.len == 0:
|
||||||
of attachedSink: typ.sink = result
|
discard "do not cache it yet"
|
||||||
of attachedDeepCopy: typ.deepCopy = result
|
else:
|
||||||
of attachedDestructor: typ.destructor = result
|
case kind
|
||||||
|
of attachedAsgn: typ.assignment = result
|
||||||
|
of attachedSink: typ.sink = result
|
||||||
|
of attachedDeepCopy: typ.deepCopy = result
|
||||||
|
of attachedDestructor: typ.destructor = result
|
||||||
|
|
||||||
var n = newNodeI(nkProcDef, info, bodyPos+1)
|
var n = newNodeI(nkProcDef, info, bodyPos+1)
|
||||||
for i in 0 ..< n.len: n.sons[i] = newNodeI(nkEmpty, info)
|
for i in 0 ..< n.len: n.sons[i] = newNodeI(nkEmpty, info)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue