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/frontend.h b/src/dmd/frontend.h index 7ccf49bd05a8..73fc9a79c847 100644 --- a/src/dmd/frontend.h +++ b/src/dmd/frontend.h @@ -389,10 +389,10 @@ enum class CHECKENABLE : uint8_t enum class CHECKACTION : uint8_t { - D = 0u, - C = 1u, - halt = 2u, - context = 3u, + context = 0u, + D = 1u, + C = 2u, + halt = 3u, }; typedef uint64_t size_t; diff --git a/src/dmd/globals.d b/src/dmd/globals.d index 691ec181ba13..00702f2433a0 100644 --- a/src/dmd/globals.d +++ b/src/dmd/globals.d @@ -44,10 +44,10 @@ enum CHECKENABLE : ubyte /// What should happend when an assertion fails 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 } /// Position Indepent Code setting @@ -193,7 +193,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 db6850804718..d439af2549c4 100644 --- a/src/dmd/globals.h +++ b/src/dmd/globals.h @@ -47,10 +47,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 JsonFieldFlags diff --git a/test/dshell/dll_cxx.d b/test/dshell/dll_cxx.d index a1e2add07da6..53f40494fa7d 100644 --- a/test/dshell/dll_cxx.d +++ b/test/dshell/dll_cxx.d @@ -56,7 +56,7 @@ int main() // The arguments have to be passed as an array, because run would replace '/' with '\\' otherwise. run(dllCmd); - run(`$DMD -m$MODEL -I$SRC -g -od=$OUTPUT_BASE -of=$EXE_NAME $SRC/testdll.d $SRC/cppnew.d ` ~ mainExtra); + run(`$DMD -m$MODEL -I$SRC -checkaction=D -g -od=$OUTPUT_BASE -of=$EXE_NAME $SRC/testdll.d $SRC/cppnew.d ` ~ mainExtra); run(`$EXE_NAME`, stdout, stderr, [`LD_LIBRARY_PATH`: Vars.OUTPUT_BASE]); diff --git a/test/runnable/complex.d b/test/runnable/complex.d index 50e793e21e6a..cb075662a7b8 100644 --- a/test/runnable/complex.d +++ b/test/runnable/complex.d @@ -1,5 +1,5 @@ /* -REQUIRED_ARGS: -d +REQUIRED_ARGS: -d -checkaction=D TEST_OUTPUT: --- --- diff --git a/test/runnable/iasm.d b/test/runnable/iasm.d index af6366d22bdc..810802f08f3f 100644 --- a/test/runnable/iasm.d +++ b/test/runnable/iasm.d @@ -1,4 +1,5 @@ // PERMUTE_ARGS: +// REQUIRED_ARGS: -checkaction=D // Copyright (c) 1999-2016 by The D Language Foundation // All Rights Reserved diff --git a/test/runnable/iasm64.d b/test/runnable/iasm64.d index 27e38f4618b7..12f8730f238a 100644 --- a/test/runnable/iasm64.d +++ b/test/runnable/iasm64.d @@ -1,4 +1,5 @@ // PERMUTE_ARGS: +// REQUIRED_ARGS: -checkaction=D // Copyright (c) 1999-2016 by The D Language Foundation // All Rights Reserved