Issue 24380 - CTFE assert messages are replaced with "null" with -dip1008
Summary: CTFE assert messages are replaced with "null" with -dip1008
Status: NEW
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All All
: P1 regression
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-02-09 19:04 UTC by JR
Modified: 2024-08-05 06:29 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description JR 2024-02-09 19:04:53 UTC
EndeavourOS/Arch x86_64, dmd 2.107.0, ldc 1.36.0, also 1.37.0-beta1.

The messages of asserts thrown during CTFE are replaced with "null" iff they were derived from a thrown exception's message and iff the program is built with -dip1008 enabled.

```d
#!/usr/bin/env dub
/+ dub.sdl:
    name "app"
    dflags "-dip1008"
+/

void main() {}

static immutable ctfeThing =
{
    try
    {
        throw new Exception("message");
    }
    catch (Exception e)
    {
        assert(0, e.msg);
    }
    return 0;
}();
```

```
app.d(17,9): Error: null
app.d(20,2):        called from here: `(*function () pure nothrow @nogc @safe => 0)()`
Error /usr/bin/dmd failed with exit code 1.
```

Expected is "Error: message", and you do get that if you disable -dip1008.
Comment 1 JR 2024-02-10 13:36:25 UTC
The behaviour changed in 2.101, before which the error message was `"message"[0..7]`.

```
$ dub build --compiler=2.100/dmd 2>&1 | grep 'Error:'
source/app.d(17,9): Error: `"message"[0..7]`

$ dub build --compiler=2.101/dmd 2>&1 | grep 'Error:' 
source/app.d(17,9): Error: `null`
```
Comment 2 Luís Ferreira 2024-08-05 06:27:55 UTC
I can confirm regression:

```
2.085.1 to 2.100.2: Failure with output: onlineapp.d(25): Error: static assert:  "Incorrect format specifier for range: %d"
Since      2.101.2: Success and no output
```