non-destructible context only produces a warning for now
This commit is contained in:
parent
afd8a902a9
commit
995510664e
2 changed files with 7 additions and 6 deletions
|
|
@ -120,7 +120,7 @@ type
|
||||||
warnDifferentHeaps, warnWriteToForeignHeap, warnUnsafeCode,
|
warnDifferentHeaps, warnWriteToForeignHeap, warnUnsafeCode,
|
||||||
warnEachIdentIsTuple, warnShadowIdent,
|
warnEachIdentIsTuple, warnShadowIdent,
|
||||||
warnProveInit, warnProveField, warnProveIndex, warnGcUnsafe, warnGcUnsafe2,
|
warnProveInit, warnProveField, warnProveIndex, warnGcUnsafe, warnGcUnsafe2,
|
||||||
warnUninit, warnGcMem, warnLockLevel, warnUser,
|
warnUninit, warnGcMem, warnDestructor, warnLockLevel, warnUser,
|
||||||
hintSuccess, hintSuccessX,
|
hintSuccess, hintSuccessX,
|
||||||
hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded,
|
hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded,
|
||||||
hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled,
|
hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled,
|
||||||
|
|
@ -392,6 +392,7 @@ const
|
||||||
warnGcUnsafe2: "cannot prove '$1' is GC-safe. Does not compile with --threads:on.",
|
warnGcUnsafe2: "cannot prove '$1' is GC-safe. Does not compile with --threads:on.",
|
||||||
warnUninit: "'$1' might not have been initialized [Uninit]",
|
warnUninit: "'$1' might not have been initialized [Uninit]",
|
||||||
warnGcMem: "'$1' uses GC'ed memory [GcMem]",
|
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]",
|
warnLockLevel: "$1 [LockLevel]",
|
||||||
warnUser: "$1 [User]",
|
warnUser: "$1 [User]",
|
||||||
hintSuccess: "operation successful [Success]",
|
hintSuccess: "operation successful [Success]",
|
||||||
|
|
@ -413,7 +414,7 @@ const
|
||||||
hintUser: "$1 [User]"]
|
hintUser: "$1 [User]"]
|
||||||
|
|
||||||
const
|
const
|
||||||
WarningsToStr*: array[0..28, string] = ["CannotOpenFile", "OctalEscape",
|
WarningsToStr*: array[0..29, string] = ["CannotOpenFile", "OctalEscape",
|
||||||
"XIsNeverRead", "XmightNotBeenInit",
|
"XIsNeverRead", "XmightNotBeenInit",
|
||||||
"Deprecated", "ConfigDeprecated",
|
"Deprecated", "ConfigDeprecated",
|
||||||
"SmallLshouldNotBeUsed", "UnknownMagic",
|
"SmallLshouldNotBeUsed", "UnknownMagic",
|
||||||
|
|
@ -423,7 +424,7 @@ const
|
||||||
"AnalysisLoophole", "DifferentHeaps", "WriteToForeignHeap",
|
"AnalysisLoophole", "DifferentHeaps", "WriteToForeignHeap",
|
||||||
"UnsafeCode", "EachIdentIsTuple", "ShadowIdent",
|
"UnsafeCode", "EachIdentIsTuple", "ShadowIdent",
|
||||||
"ProveInit", "ProveField", "ProveIndex", "GcUnsafe", "GcUnsafe2", "Uninit",
|
"ProveInit", "ProveField", "ProveIndex", "GcUnsafe", "GcUnsafe2", "Uninit",
|
||||||
"GcMem", "LockLevel", "User"]
|
"GcMem", "Destructor", "LockLevel", "User"]
|
||||||
|
|
||||||
HintsToStr*: array[0..16, string] = ["Success", "SuccessX", "LineTooLong",
|
HintsToStr*: array[0..16, string] = ["Success", "SuccessX", "LineTooLong",
|
||||||
"XDeclaredButNotUsed", "ConvToBaseNotNeeded", "ConvFromXtoItselfNotNeeded",
|
"XDeclaredButNotUsed", "ConvToBaseNotNeeded", "ConvFromXtoItselfNotNeeded",
|
||||||
|
|
|
||||||
|
|
@ -92,10 +92,10 @@ proc semProc(c: PContext, n: PNode): PNode
|
||||||
include semdestruct
|
include semdestruct
|
||||||
|
|
||||||
proc semDestructorCheck(c: PContext, n: PNode, flags: TExprFlags) {.inline.} =
|
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:
|
if instantiateDestructor(c, n.typ) != nil:
|
||||||
localError(n.info, errGenerated,
|
localError(n.info, warnDestructor)
|
||||||
"usage of a type with a destructor in a non destructible context")
|
|
||||||
# This still breaks too many things:
|
# This still breaks too many things:
|
||||||
when false:
|
when false:
|
||||||
if efDetermineType notin flags and n.typ.kind == tyTypeDesc and
|
if efDetermineType notin flags and n.typ.kind == tyTypeDesc and
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue