Bug 10041 – ufcs writeln of associative array

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-07T15:02:00Z
Last change time
2013-05-08T04:11:36Z
Keywords
pull, wrong-code
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2013-05-07T15:02:36Z
I don't know if this a Phobos or DMD bug. import std.stdio: writeln; void main () { auto aa = [1: 2]; aa.writeln; writeln(aa); } Output with dmd 2.063beta: AssociativeArray!(int, int)(18C2FE0) [1:2] Expected something like: [1: 2] [1: 2]
Comment #1 by k.hara.pg — 2013-05-07T17:40:47Z
(In reply to comment #0) > I don't know if this a Phobos or DMD bug. This is a regression in 2.063a. https://github.com/D-Programming-Language/dmd/pull/1975
Comment #2 by bearophile_hugs — 2013-05-07T18:05:43Z
(In reply to comment #1) > (In reply to comment #0) > > I don't know if this a Phobos or DMD bug. > > This is a regression in 2.063a. > > https://github.com/D-Programming-Language/dmd/pull/1975 Thank you Kenji. - - - - - - - A mostly unrelated question. Python dict formatting uses a space after the colon, probably to increase readability: >>> {1:2, 2:3} {1: 2, 2: 3} I kind of like that extra space. Is it a good idea to add it to D AA formatting?
Comment #3 by k.hara.pg — 2013-05-07T18:22:04Z
(In reply to comment #2) > A mostly unrelated question. Python dict formatting uses a space after the > colon, probably to increase readability: > > >>> {1:2, 2:3} > {1: 2, 2: 3} > > I kind of like that extra space. Is it a good idea to add it to D AA > formatting? I have no argument about the space after colon... void main() { import std.stdio; // Fixed a while ago pragma(msg, [1, 2]); // [1, 2] writeln([1, 2]); // [1, 2] // Currently different output between compiler and std-lib pragma(msg, [1:1, 2:2]); // [1:1,2:2] writeln([1:1, 2:2]); // [1:1, 2:2] } Both compiler and Phobos prints no space after colon. Currently it is consistent. But, I can argue that compiler should insert a space after comma in AA literal printing.
Comment #4 by github-bugzilla — 2013-05-08T03:51:49Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/259af5ff9e7f4231f5ce8df00b8f1d81e90042fe fix Issue 10041 - ufcs writeln of associative array https://github.com/D-Programming-Language/dmd/commit/e6ccdf5d43c75d87dc0a777760830b2b2e7fe3ee Merge pull request #1975 from 9rnsr/fix10041 [REG2.063a] Issue 10041 - ufcs writeln of associative array