From 995510664e543ff74a10750e804767443429d5f8 Mon Sep 17 00:00:00 2001 From: Araq Date: Sat, 24 Jan 2015 00:24:14 +0100 Subject: [PATCH] non-destructible context only produces a warning for now --- compiler/msgs.nim | 7 ++++--- compiler/semstmts.nim | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/compiler/msgs.nim b/compiler/msgs.nim index 17b2c4606..d94b8ade8 100644 --- a/compiler/msgs.nim +++ b/compiler/msgs.nim @@ -120,7 +120,7 @@ type warnDifferentHeaps, warnWriteToForeignHeap, warnUnsafeCode, warnEachIdentIsTuple, warnShadowIdent, warnProveInit, warnProveField, warnProveIndex, warnGcUnsafe, warnGcUnsafe2, - warnUninit, warnGcMem, warnLockLevel, warnUser, + warnUninit, warnGcMem, warnDestructor, warnLockLevel, warnUser, hintSuccess, hintSuccessX, hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded, hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled, @@ -392,6 +392,7 @@ const warnGcUnsafe2: "cannot prove '$1' is GC-safe. Does not compile with --threads:on.", warnUninit: "'$1' might not have been initialized [Uninit]", warnGcMem: "'$1' uses GC'ed memory [GcMem]", + warnDestructor: "usage of a type with a destructor in a non destructible context. This will become a compile time error in the future. [Destructor]", warnLockLevel: "$1 [LockLevel]", warnUser: "$1 [User]", hintSuccess: "operation successful [Success]", @@ -413,7 +414,7 @@ const hintUser: "$1 [User]"] const - WarningsToStr*: array[0..28, string] = ["CannotOpenFile", "OctalEscape", + WarningsToStr*: array[0..29, string] = ["CannotOpenFile", "OctalEscape", "XIsNeverRead", "XmightNotBeenInit", "Deprecated", "ConfigDeprecated", "SmallLshouldNotBeUsed", "UnknownMagic", @@ -423,7 +424,7 @@ const "AnalysisLoophole", "DifferentHeaps", "WriteToForeignHeap", "UnsafeCode", "EachIdentIsTuple", "ShadowIdent", "ProveInit", "ProveField", "ProveIndex", "GcUnsafe", "GcUnsafe2", "Uninit", - "GcMem", "LockLevel", "User"] + "GcMem", "Destructor", "LockLevel", "User"] HintsToStr*: array[0..16, string] = ["Success", "SuccessX", "LineTooLong", "XDeclaredButNotUsed", "ConvToBaseNotNeeded", "ConvFromXtoItselfNotNeeded", diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index fe12d9610..565d4db06 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -92,10 +92,10 @@ proc semProc(c: PContext, n: PNode): PNode include semdestruct proc semDestructorCheck(c: PContext, n: PNode, flags: TExprFlags) {.inline.} = - if efAllowDestructor notin flags and n.kind in nkCallKinds+{nkObjConstr}: + if efAllowDestructor notin flags and + n.kind in nkCallKinds+{nkObjConstr,nkBracket}: if instantiateDestructor(c, n.typ) != nil: - localError(n.info, errGenerated, - "usage of a type with a destructor in a non destructible context") + localError(n.info, warnDestructor) # This still breaks too many things: when false: if efDetermineType notin flags and n.typ.kind == tyTypeDesc and