From eb919c35b29afee8fb26a2145d88f4db9e6c332b Mon Sep 17 00:00:00 2001 From: Andreas Rumpf Date: Mon, 26 Nov 2018 10:41:26 +0100 Subject: [PATCH] fixes #9675 --- compiler/ast.nim | 4 ++-- compiler/ccgexprs.nim | 1 + compiler/jsgen.nim | 1 + compiler/vmgen.nim | 1 + lib/system.nim | 2 +- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/compiler/ast.nim b/compiler/ast.nim index e509d2ceb8..7cf35450bd 100644 --- a/compiler/ast.nim +++ b/compiler/ast.nim @@ -627,7 +627,7 @@ type mIsPartOf, mAstToStr, mParallel, mSwap, mIsNil, mArrToSeq, mCopyStr, mCopyStrLast, mNewString, mNewStringOfCap, mParseBiggestFloat, - mMove, mWasMoved, + mMove, mWasMoved, mDestroy, mReset, mArray, mOpenArray, mRange, mSet, mSeq, mOpt, mVarargs, mRef, mPtr, mVar, mDistinct, mVoid, mTuple, @@ -664,7 +664,7 @@ const ctfeWhitelist* = {mNone, mUnaryLt, mSucc, mPred, mInc, mDec, mOrd, mLengthOpenArray, mLengthStr, mLengthArray, mLengthSeq, mXLenStr, mXLenSeq, - mArrGet, mArrPut, mAsgn, + mArrGet, mArrPut, mAsgn, mDestroy, mIncl, mExcl, mCard, mChr, mAddI, mSubI, mMulI, mDivI, mModI, mAddF64, mSubF64, mMulF64, mDivF64, diff --git a/compiler/ccgexprs.nim b/compiler/ccgexprs.nim index 40a5d674c3..fe3d676d87 100644 --- a/compiler/ccgexprs.nim +++ b/compiler/ccgexprs.nim @@ -2034,6 +2034,7 @@ proc genMagicExpr(p: BProc, e: PNode, d: var TLoc, op: TMagic) = of mDotDot, mEqCString: genCall(p, e, d) of mWasMoved: genWasMoved(p, e) of mMove: genMove(p, e, d) + of mDestroy: discard "ignore calls to the default destructor" of mSlice: localError(p.config, e.info, "invalid context for 'toOpenArray'; " & " 'toOpenArray' is only valid within a call expression") diff --git a/compiler/jsgen.nim b/compiler/jsgen.nim index 19bbde7777..3af34c03b7 100644 --- a/compiler/jsgen.nim +++ b/compiler/jsgen.nim @@ -1760,6 +1760,7 @@ proc genMagic(p: PProc, n: PNode, r: var TCompRes) = of mEnumToStr: genRepr(p, n, r) of mNew, mNewFinalize: genNew(p, n) of mChr, mArrToSeq: gen(p, n.sons[1], r) # nothing to do + of mDestroy: discard "ignore calls to the default destructor" of mOrd: genOrd(p, n, r) of mLengthStr, mLengthSeq, mLengthOpenArray, mLengthArray: unaryExpr(p, n, r, "", "($1 != null ? $1.length : 0)") diff --git a/compiler/vmgen.nim b/compiler/vmgen.nim index e52f460d29..aef40346ff 100644 --- a/compiler/vmgen.nim +++ b/compiler/vmgen.nim @@ -1259,6 +1259,7 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) = globalError(c.config, n.info, "cannot evaluate 'sizeof/alignof' because its type is not defined completely") of mRunnableExamples: discard "just ignore any call to runnableExamples" + of mDestroy: discard "ignore calls to the default destructor" else: # mGCref, mGCunref, globalError(c.config, n.info, "cannot generate code for: " & $m) diff --git a/lib/system.nim b/lib/system.nim index e8b427c554..4414c21071 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -373,7 +373,7 @@ when defined(nimArrIdx): x: S) {.noSideEffect, magic: "ArrPut".} when defined(nimNewRuntime): - proc `=destroy`*[T](x: var T) {.inline, magic: "Asgn".} = + proc `=destroy`*[T](x: var T) {.inline, magic: "Destroy".} = ## generic `destructor`:idx: implementation that can be overriden. discard proc `=sink`*[T](x: var T; y: T) {.inline, magic: "Asgn".} =