This commit is contained in:
Andreas Rumpf 2021-07-22 09:37:41 +02:00 • committed by GitHub
commit 58e27ebd4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 3 deletions

View file

@ -1064,7 +1064,7 @@ proc getPIdent*(a: PNode): PIdent {.inline.} =
# which may simplify code.
case a.kind
of nkSym: a.sym.name
of nkIdent: a.ident
of nkIdent: a.ident
else: nil
proc getnimblePkg*(a: PSym): PSym =

View file

@ -71,6 +71,7 @@ type
warnCannotOpen = "CannotOpen",
warnFileChanged = "FileChanged",
warnSuspiciousEnumConv = "EnumConv",
warnAnyEnumConv = "AnyEnumConv",
warnCstringConv = "CStringConv",
warnUser = "User",
# hints
@ -156,6 +157,7 @@ const
warnCannotOpen: "cannot open: $1",
warnFileChanged: "file changed: $1",
warnSuspiciousEnumConv: "$1",
warnAnyEnumConv: "$1",
warnCstringConv: "$1",
warnUser: "$1",
hintSuccess: "operation successful: $#",
@ -211,7 +213,7 @@ type
TNoteKinds* = set[TNoteKind]
proc computeNotesVerbosity(): array[0..3, TNoteKinds] =
result[3] = {low(TNoteKind)..high(TNoteKind)} - {warnObservableStores, warnResultUsed}
result[3] = {low(TNoteKind)..high(TNoteKind)} - {warnObservableStores, warnResultUsed, warnAnyEnumConv}
result[2] = result[3] - {hintStackTrace, warnUninit, hintExtendedContext, hintDeclaredLoc, hintProcessingStmt}
result[1] = result[2] - {warnProveField, warnProveIndex,
warnGcUnsafe, hintPath, hintDependency, hintCodeBegin, hintCodeEnd,

View file

@ -1171,7 +1171,10 @@ proc track(tracked: PEffects, n: PNode) =
not allowCStringConv(n[1]):
message(tracked.config, n.info, warnCstringConv,
"implicit conversion to 'cstring' from a non-const location: $1; this will become a compile time error in the future" %
[$n[1]])
$n[1])
if n.typ.skipTypes(abstractInst).kind == tyEnum:
message(tracked.config, n.info, warnAnyEnumConv, "enum conversion: $1" % $n[1])
if n.len == 2:
track(tracked, n[1])