diff options
author | Clyybber <darkmine956@gmail.com> | 2020-06-29 08:49:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-29 08:49:53 +0200 |
commit | 299ddda5f6eaceab0bde443159bd17bab1cdf2f1 (patch) | |
tree | 42b158d7ef0f62a3f98552fbf7102cd7f5cc714c /compiler | |
parent | 37325564689c638ef409c79b8380d7564f173c72 (diff) | |
download | Nim-299ddda5f6eaceab0bde443159bd17bab1cdf2f1.tar.gz |
Make unreachable code a warning instead of an error (#14816)
* Make unreachable code a warning * Adapt test * Trigger CI
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/lineinfos.nim | 6 | ||||
-rw-r--r-- | compiler/semstmts.nim | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/compiler/lineinfos.nim b/compiler/lineinfos.nim index 6287e21aa..378e06c72 100644 --- a/compiler/lineinfos.nim +++ b/compiler/lineinfos.nim @@ -49,7 +49,8 @@ type warnEachIdentIsTuple, warnUnsafeSetLen, warnUnsafeDefault, - warnProveInit, warnProveField, warnProveIndex, warnUnreachableElse, + warnProveInit, warnProveField, warnProveIndex, + warnUnreachableElse, warnUnreachableCode, warnStaticIndexCheck, warnGcUnsafe, warnGcUnsafe2, warnUninit, warnGcMem, warnDestructor, warnLockLevel, warnResultShadowed, warnInconsistentSpacing, warnCaseTransition, warnCycleCreated, @@ -110,6 +111,7 @@ const warnProveField: "cannot prove that field '$1' is accessible", warnProveIndex: "cannot prove index '$1' is valid", warnUnreachableElse: "unreachable else, all cases are already covered", + warnUnreachableCode: "unreachable code after 'return' statement or '{.noReturn.}' proc", warnStaticIndexCheck: "$1", warnGcUnsafe: "not GC-safe: '$1'", warnGcUnsafe2: "$1", @@ -169,7 +171,7 @@ const "UnsafeCode", "UnusedImport", "InheritFromException", "EachIdentIsTuple", "UnsafeSetLen", "UnsafeDefault", - "ProveInit", "ProveField", "ProveIndex", "UnreachableElse", + "ProveInit", "ProveField", "ProveIndex", "UnreachableElse", "UnreachableCode", "IndexCheck", "GcUnsafe", "GcUnsafe2", "Uninit", "GcMem", "Destructor", "LockLevel", "ResultShadowed", "Spacing", "CaseTransition", "CycleCreated", diff --git a/compiler/semstmts.nim b/compiler/semstmts.nim index 5875a3b68..47a5130af 100644 --- a/compiler/semstmts.nim +++ b/compiler/semstmts.nim @@ -2269,10 +2269,8 @@ proc semStmtList(c: PContext, n: PNode, flags: TExprFlags): PNode = sfNoReturn in n[i][0].sym.flags: for j in i + 1..<n.len: case n[j].kind - of nkPragma, nkCommentStmt, nkNilLit, nkEmpty, nkBlockExpr, - nkBlockStmt, nkState: discard - else: localError(c.config, n[j].info, - "unreachable statement after 'return' statement or '{.noReturn.}' proc") + of nkPragma, nkCommentStmt, nkNilLit, nkEmpty, nkState: discard + else: message(c.config, n[j].info, warnUnreachableCode) else: discard if result.len == 1 and |