From 9cbdab897846781b69bd9dd88d43748b3e5dcc4e Mon Sep 17 00:00:00 2001 From: Sebastian Wilzbach Date: Thu, 16 Aug 2018 10:38:11 +0200 Subject: [PATCH] Fix Issue 19087 - final switch cannot be used in -betterC --- src/core/exception.d | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/core/exception.d b/src/core/exception.d index c16894554c..7de406a9a2 100644 --- a/src/core/exception.d +++ b/src/core/exception.d @@ -574,14 +574,20 @@ extern (C) void onInvalidMemoryOperationError(void* pretend_sideffect = null) @t */ extern (C) void onSwitchError( string file = __FILE__, size_t line = __LINE__ ) @safe pure nothrow { - throw new SwitchError( file, line, null ); + version (D_Exceptions) + throw new SwitchError( file, line, null ); + else + assert(0, "No appropriate switch clause found"); } // Compiler lowers final switch default case to this (which is a runtime error) void __switch_errorT()(string file = __FILE__, size_t line = __LINE__) @trusted { // Consider making this a compile time check. - throw staticError!SwitchError(file, line, null); + version (D_Exceptions) + throw staticError!SwitchError(file, line, null); + else + assert(0, "No appropriate switch clause found"); } /**