feature: the compiler can warn when you use the implicit 'result' variable (#17988) [backport:1.2]
* implements #17855
This commit is contained in:
parent
a9ae5fe5be
commit
378ee7f888
3 changed files with 7 additions and 2 deletions
|
|
@ -60,6 +60,7 @@ type
|
|||
warnInconsistentSpacing = "Spacing", warnCaseTransition = "CaseTransition",
|
||||
warnCycleCreated = "CycleCreated", warnObservableStores = "ObservableStores",
|
||||
warnStrictNotNil = "StrictNotNil",
|
||||
warnResultUsed = "ResultUsed",
|
||||
warnCannotOpen = "CannotOpen",
|
||||
warnFileChanged = "FileChanged",
|
||||
warnUser = "User",
|
||||
|
|
@ -138,6 +139,7 @@ const
|
|||
warnCycleCreated: "$1",
|
||||
warnObservableStores: "observable stores to '$1'",
|
||||
warnStrictNotNil: "$1",
|
||||
warnResultUsed: "used 'result' variable",
|
||||
warnCannotOpen: "cannot open: $1",
|
||||
warnFileChanged: "file changed: $1",
|
||||
warnUser: "$1",
|
||||
|
|
@ -193,7 +195,7 @@ type
|
|||
TNoteKinds* = set[TNoteKind]
|
||||
|
||||
proc computeNotesVerbosity(): array[0..3, TNoteKinds] =
|
||||
result[3] = {low(TNoteKind)..high(TNoteKind)} - {warnObservableStores}
|
||||
result[3] = {low(TNoteKind)..high(TNoteKind)} - {warnObservableStores, warnResultUsed}
|
||||
result[2] = result[3] - {hintStackTrace, warnUninit, hintExtendedContext, hintDeclaredLoc}
|
||||
result[1] = result[2] - {warnProveField, warnProveIndex,
|
||||
warnGcUnsafe, hintPath, hintDependency, hintCodeBegin, hintCodeEnd,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue