diff options
author | genotrance <dev@genotrance.com> | 2019-06-01 23:40:07 -0500 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2019-06-02 06:40:07 +0200 |
commit | 1255b3c8647c2ad4be831698633eaf2f4a38795c (patch) | |
tree | 19c6065007c3bd217affd522fb8981660832b19a | |
parent | 4a35d2b571190e94e151091535793cd033b589b1 (diff) | |
download | Nim-1255b3c8647c2ad4be831698633eaf2f4a38795c.tar.gz |
Warn about object case transitions at compile time (#11378)
-rw-r--r-- | compiler/ccgstmts.nim | 1 | ||||
-rw-r--r-- | compiler/lineinfos.nim | 5 |
2 files changed, 4 insertions, 2 deletions
diff --git a/compiler/ccgstmts.nim b/compiler/ccgstmts.nim index eed046afd..5ddf78a76 100644 --- a/compiler/ccgstmts.nim +++ b/compiler/ccgstmts.nim @@ -1274,6 +1274,7 @@ proc genAsgn(p: BProc, e: PNode, fastAsgn: bool) = else: genLineDir(p, e) asgnFieldDiscriminant(p, e) + message(p.config, e.info, warnCaseTransition) proc genStmts(p: BProc, t: PNode) = var a: TLoc diff --git a/compiler/lineinfos.nim b/compiler/lineinfos.nim index b84d8c895..694ae8e94 100644 --- a/compiler/lineinfos.nim +++ b/compiler/lineinfos.nim @@ -36,7 +36,7 @@ type warnEachIdentIsTuple, warnProveInit, warnProveField, warnProveIndex, warnGcUnsafe, warnGcUnsafe2, warnUninit, warnGcMem, warnDestructor, warnLockLevel, warnResultShadowed, - warnInconsistentSpacing, warnUser, + warnInconsistentSpacing, warnCaseTransition, warnUser, hintSuccess, hintSuccessX, hintCC, hintLineTooLong, hintXDeclaredButNotUsed, hintConvToBaseNotNeeded, hintConvFromXtoItselfNotNeeded, hintExprAlwaysX, hintQuitCalled, @@ -90,6 +90,7 @@ const warnLockLevel: "$1", warnResultShadowed: "Special variable 'result' is shadowed.", warnInconsistentSpacing: "Number of spaces around '$#' is not consistent", + warnCaseTransition: "Potential object case transition, instantiate new object instead", warnUser: "$1", hintSuccess: "operation successful: $#", hintSuccessX: "operation successful ($# lines compiled; $# sec total; $#; $#)", @@ -135,7 +136,7 @@ const "UnsafeCode", "EachIdentIsTuple", "ProveInit", "ProveField", "ProveIndex", "GcUnsafe", "GcUnsafe2", "Uninit", "GcMem", "Destructor", "LockLevel", "ResultShadowed", - "Spacing", "User"] + "Spacing", "CaseTransition", "User"] HintsToStr* = [ "Success", "SuccessX", "CC", "LineTooLong", |