Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.

Commit 9cbdab8

Browse files
wilzbachn8sh
authored andcommitted
Fix Issue 19087 - final switch cannot be used in -betterC
1 parent 711ab1c commit 9cbdab8

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/core/exception.d

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,14 +574,20 @@ extern (C) void onInvalidMemoryOperationError(void* pretend_sideffect = null) @t
574574
*/
575575
extern (C) void onSwitchError( string file = __FILE__, size_t line = __LINE__ ) @safe pure nothrow
576576
{
577-
throw new SwitchError( file, line, null );
577+
version (D_Exceptions)
578+
throw new SwitchError( file, line, null );
579+
else
580+
assert(0, "No appropriate switch clause found");
578581
}
579582

580583
// Compiler lowers final switch default case to this (which is a runtime error)
581584
void __switch_errorT()(string file = __FILE__, size_t line = __LINE__) @trusted
582585
{
583586
// Consider making this a compile time check.
584-
throw staticError!SwitchError(file, line, null);
587+
version (D_Exceptions)
588+
throw staticError!SwitchError(file, line, null);
589+
else
590+
assert(0, "No appropriate switch clause found");
585591
}
586592

587593
/**

0 commit comments

Comments
 (0)