Skip to content

Commit

Permalink
Enable -checkaction=context by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Geod24 committed Mar 25, 2021
1 parent 7612890 commit a9c3170
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
15 changes: 15 additions & 0 deletions 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`.
5 changes: 3 additions & 2 deletions src/dmd/globals.d
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/dmd/globals.h
Expand Up @@ -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
Expand Down

0 comments on commit a9c3170

Please sign in to comment.