Bug 17627 – DMD's toChars should not include the entire array of a slice result

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-07-09T17:51:59Z
Last change time
2024-12-13T18:53:14Z
Keywords
diagnostic
Assigned to
No Owner
Creator
Andre
Moved to GitHub: dmd#19278 →

Comments

Comment #0 by andre — 2017-07-09T17:51:59Z
assert(false, strVar) has to be used to output a string variable in CTFE. At the moment there is no other possibility as pragma(msg, ...) and writeln is not working. Also with the new CTFE it isn't 100% clear whether ctfeWriteln will come: http://forum.dlang.org/post/[email protected] For this example string test(string s) { string tmp = s; tmp = tmp[4..$]; assert(false, tmp); return tmp; } enum foo = `1234 5678 `; void main() { enum bar = test(foo); } The output is (dmd 2.075.0-b2): C:\Users\user\Desktop>rdmd app app.d(6): Error: "1234\x0a5678\x0a"[4..10] app.d(17): called from here: test("1234\x0a5678\x0a") Failed: ["dmd", "-v", "-o-", "app.d", "-I."] Instead of the content of tmp, the full content is shown with the slice information [4..10]. This output is in a real scenario quite irritating as the string is much longer and a lot more logic is going on and also the string isn't passed back but a structure. I already thought dmd isn't working at all, as the tmp variable didn't changed its value. Only after having 5 looks at the minimal example output, I saw the slice information.
Comment #1 by robert.schadek — 2024-12-13T18:53:14Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19278 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB