From a9c3170c193679632b1c3023fc77d9447e6570e5 Mon Sep 17 00:00:00 2001 From: Geod24 Date: Thu, 5 Nov 2020 18:02:21 +0900 Subject: [PATCH] Enable -checkaction=context by default --- changelog/checkaction-context-default.dd | 15 +++++++++++++++ src/dmd/globals.d | 5 +++-- src/dmd/globals.h | 4 ++-- 3 files changed, 20 insertions(+), 4 deletions(-) create mode 100644 changelog/checkaction-context-default.dd diff --git a/changelog/checkaction-context-default.dd b/changelog/checkaction-context-default.dd new file mode 100644 index 000000000000..54bfce3275ee --- /dev/null +++ b/changelog/checkaction-context-default.dd @@ -0,0 +1,15 @@ +Enhanced `assert` informations are now printed by default + +Starting from this release, DMD will now print rich informations on assert failures. +For example, the following code: +--- +void main () +{ + int a = 0, b = 42; + assert(a == b); +} +--- + +Will now print: `core.exception.AssertError@filename.d(4): 0 != 42`. +This behavior was previously accessible via the CLI switch `-checkaction=context`. +To revert to the old behavior, use `-checkaction=D`. diff --git a/src/dmd/globals.d b/src/dmd/globals.d index 4b5112867436..1549a97e6216 100644 --- a/src/dmd/globals.d +++ b/src/dmd/globals.d @@ -75,10 +75,10 @@ enum CHECKENABLE : ubyte enum CHECKACTION : ubyte { + context, // call D assert with the error context on failure D, // call D assert on failure C, // call C assert on failure halt, // cause program halt on failure - context, // call D assert with the error context on failure } enum CPU @@ -248,7 +248,8 @@ extern (C++) struct Param CHECKENABLE useSwitchError = CHECKENABLE._default; // check for switches without a default CHECKENABLE boundscheck = CHECKENABLE._default; // state of -boundscheck switch - CHECKACTION checkAction = CHECKACTION.D; // action to take when bounds, asserts or switch defaults are violated + /// Action to take when bounds, asserts or switch defaults are violated + CHECKACTION checkAction = CHECKACTION.context; uint errorLimit = 20; diff --git a/src/dmd/globals.h b/src/dmd/globals.h index b16362e2a447..cfd32b977b76 100644 --- a/src/dmd/globals.h +++ b/src/dmd/globals.h @@ -67,10 +67,10 @@ enum typedef unsigned char CHECKACTION; enum { + CHECKACTION_context, // call D assert with the error context on failure CHECKACTION_D, // call D assert on failure CHECKACTION_C, // call C assert on failure - CHECKACTION_halt, // cause program halt on failure - CHECKACTION_context // call D assert with the error context on failure + CHECKACTION_halt // cause program halt on failure }; enum class CPU