Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable -checkaction=context by default #11925

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions .circleci/run.sh
Expand Up @@ -10,6 +10,7 @@ CIRCLE_STAGE=${CIRCLE_STAGE:-pic}
CIRCLE_PROJECT_REPONAME=${CIRCLE_PROJECT_REPONAME:-dmd}
BUILD="debug"
DMD=dmd
OS=linux

case $CIRCLE_NODE_INDEX in
0) MODEL=64 ;;
Expand Down Expand Up @@ -111,7 +112,7 @@ coverage()
# load environment for bootstrap compiler
source "$(CURL_USER_AGENT=\"$CURL_USER_AGENT\" bash ~/dlang/install.sh dmd-$HOST_DMD_VER --activate)"

local build_path=generated/linux/$BUILD/$MODEL
local build_path=generated/$OS/$BUILD/$MODEL
local builder=generated/build

dmd -g -od=generated -of=$builder compiler/src/build
Expand Down Expand Up @@ -163,7 +164,7 @@ check_clean_git()
# sanitycheck for the run_individual_tests script
check_run_individual()
{
local build_path=generated/linux/$BUILD/$MODEL
local build_path=generated/$OS/$BUILD/$MODEL
"${build_path}/dmd" -Icompiler/test -i -run ./compiler/test/run.d "BUILD=$BUILD" "MODEL=$MODEL" compiler/test/runnable/template2962.d ./compiler/test/compilable/test14275.d
}

Expand All @@ -177,7 +178,7 @@ check_d_builder()
rm -rf generated # just to be sure
# TODO: add support for 32-bit builds
./compiler/src/build.d MODEL=64
./generated/linux/release/64/dmd --version | grep -v "dirty"
./generated/$OS/release/64/dmd --version | grep -v "dirty"
./compiler/src/build.d clean
deactivate
}
Expand Down
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 compiler/src/dmd/frontend.h
Expand Up @@ -3006,10 +3006,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,
};

struct Output final
Expand Down
5 changes: 3 additions & 2 deletions compiler/src/dmd/globals.d
Expand Up @@ -41,10 +41,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
}

/**
Expand Down Expand Up @@ -175,7 +175,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;
uint errorSupplementLimit = 6; // Limit the number of supplemental messages for each error (0 means unlimited)
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dmd/globals.h
Expand Up @@ -50,10 +50,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 compiler/test/dshell/dll_cxx.d
Expand Up @@ -53,7 +53,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: 2 additions & 0 deletions compiler/test/run.d
Expand Up @@ -288,6 +288,8 @@ void ensureToolsExists(const string[string] env, const TestTool[] tools ...)
// DMD compiler under test
command = [
env["DMD"],
// Do not depend on linking Phobos, especially for `dshell_prebuilt`
"-checkaction=D",
"-conf=",
"-m"~env["MODEL"],
"-of" ~ targetBin,
Expand Down
2 changes: 1 addition & 1 deletion compiler/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 compiler/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 compiler/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