Bug 24036 – assert message in CTFE becomes `['m', 'e', 's', 's', 'a', 'g', 'e'][0..7]` if produced using std.format.format
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2023-07-07T05:02:21Z
Last change time
2023-08-08T15:10:10Z
Keywords
pull
Assigned to
No Owner
Creator
JR
Comments
Comment #0 by zorael — 2023-07-07T05:02:21Z
Manjaro/Arch x86_64, dmd 2.104.0, ldc 1.33-beta2.
If I assert(0) in CTFE with a message string produced with std.format.format, it is output to the terminal as an `['f', 'o', 'o'][0..3]` array, and not as a string. If I make it a string literal it works as you'd expect. cast(string) does not seem to help. .idup makes it "foo[0..3]".
https://run.dlang.io/is/94RE0Y
---
import std;
static immutable ctfeThing = ()
{
assert(0, format("%s", "message"));
return 42;
}();
void main() {}
---
Comment #1 by dlang-bot — 2023-08-08T11:12:40Z
@dkorpel created dlang/dmd pull request #15517 "Fix 24036 - assert message in CTFE becomes `['m', 'e'`..." fixing this issue:
- Fix 24036 - assert message in CTFE becomes `['m', 'e'`...
https://github.com/dlang/dmd/pull/15517
Comment #2 by dlang-bot — 2023-08-08T15:10:10Z
dlang/dmd pull request #15517 "Fix 24036 - assert message in CTFE becomes `['m', 'e'`..." was merged into master:
- be13c99e3f231e1f93c3593805fb725a5c2a0eaa by Dennis Korpel:
Fix 24036 - assert message in CTFE becomes `['m', 'e'`...
https://github.com/dlang/dmd/pull/15517