Bug 6559 – Compiler message expression formatting does not match phobos

Status
RESOLVED
Resolution
WORKSFORME
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-08-26T11:30:00Z
Last change time
2012-12-27T23:33:41Z
Keywords
diagnostic
Assigned to
nobody
Creator
bus_dbugzilla

Comments

Comment #0 by bus_dbugzilla — 2011-08-26T11:30:41Z
> type testArrayOut.d import std.stdio; immutable arr = [ 1 , 2 , 3 ]; void main() { pragma(msg, arr); writeln(arr); } > dmd testArrayOut.d [1,2,3] > testArrayOut [1, 2, 3] The formatting should be the same at both runtime and compile-time.
Comment #1 by clugdbug — 2011-08-29T00:51:37Z
(In reply to comment #0) > > type testArrayOut.d > import std.stdio; > immutable arr = [ 1 , 2 , 3 ]; > void main() > { > pragma(msg, arr); > writeln(arr); > } > > > dmd testArrayOut.d > [1,2,3] > > > testArrayOut > [1, 2, 3] > > The formatting should be the same at both runtime and compile-time. You're assuming that pragma(msg) and writeln use the same format, but I'm not sure why. AFAIK there is nothing in the spec that should give that impression. They are completely unrelated features. pragma(msg) uses the same format that is used for error messages.
Comment #2 by yebblies — 2012-01-27T23:22:15Z
I agree with Don. This is asking for dmd's value formatting to match what phobos currently does. The fact it doesn't is not a bug. Does not involve CTFE.
Comment #3 by andrej.mitrovich — 2012-12-27T17:55:28Z
Incidentally it seems to be fixed: D:\dev\code\d_code>rdmd test.d [1, 2, 3] -- CT DMD v2.061 DEBUG [1, 2, 3] -- RT It really is invalid to ask CT pragma to match Phobos formatters. Note however that the new format in 2.061 works at compile-time, therefore you can have a 100% match if you use it in a pragma: import std.stdio; import std.string; immutable arr = [ 1 , 2 , 3 ]; void main() { pragma(msg, format("%s", arr)); } In 2.060 you can use xformat instead.
Comment #4 by bugzilla — 2012-12-27T21:10:29Z
"seems to be fixed" should be resolves as "WORKSFORME".
Comment #5 by k.hara.pg — 2012-12-27T23:33:41Z
(In reply to comment #3) > Incidentally it seems to be fixed: > > D:\dev\code\d_code>rdmd test.d > [1, 2, 3] -- CT > DMD v2.061 DEBUG > [1, 2, 3] -- RT > > It really is invalid to ask CT pragma to match Phobos formatters. As a side note, this change is introduced by fixing issue 2273. https://github.com/D-Programming-Language/dmd/commit/04891ca1e554d46be873ebe607ddeb614d934e57 An array literal formatting in CT uses argsToCBuffer in expression.c, and it is also used for ddoc formatting.