[Issue 21808] New: Position format specifiers don't work for AAs

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Apr 7 22:49:25 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=21808

          Issue ID: 21808
           Summary: Position format specifiers don't work for AAs
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: qs.il.paperinik at gmail.com

When formatting AAs, one can use %(..%|..%) where the left side formats
key--value pairs using two format specifiers. Here, positional formatting of
the form %1$..s does not do its job. Position arguments are ignored.

Test case:

    import std.stdio;
    auto spelled = [ 1 : "one", 10 : "ten", 100 : "hundred" ];

    // expected: prints, in any order, 1 (one), 10 (ten), 100 (hundred)
    // result: prints, in any order, 1 (one), 10 (ten), 100 (hundred) [ok]
    writefln("%-(%1$s (%2$s)%|, %)", spelled);

    // expected: prints, in any order, one (1), ten (10), hundred (100)
    // result: prints, in any order, 1 (one), 10 (ten), 100 (hundred) [fail]
    writefln("%-(%2$s (%1$s)%|, %)", spelled);

--


More information about the Digitalmars-d-bugs mailing list