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 Oct 19, 2021
1 parent 5005dbc commit ac55335
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 10 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`.
8 changes: 4 additions & 4 deletions src/dmd/frontend.h
Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions src/dmd/globals.d
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/dmd/globals.h
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/dshell/dll_cxx.d
Expand Up @@ -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]);

Expand Down
2 changes: 1 addition & 1 deletion test/runnable/complex.d
@@ -1,5 +1,5 @@
/*
REQUIRED_ARGS: -d
REQUIRED_ARGS: -d -checkaction=D
TEST_OUTPUT:
---
---
Expand Down
1 change: 1 addition & 0 deletions 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
Expand Down
1 change: 1 addition & 0 deletions 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
Expand Down

0 comments on commit ac55335

Please sign in to comment.