From 299ddda5f6eaceab0bde443159bd17bab1cdf2f1 Mon Sep 17 00:00:00 2001 From: Clyybber Date: Mon, 29 Jun 2020 08:49:53 +0200 Subject: Make unreachable code a warning instead of an error (#14816) * Make unreachable code a warning * Adapt test * Trigger CI --- compiler/lineinfos.nim | 6 ++++-- compiler/semstmts.nim | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'compiler') 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..