https://issues.dlang.org/show_bug.cgi?id=16336
Issue ID: 16336 Summary: Inconsistent flag handling of std.format.FormatSpec Product: D Version: D2 Hardware: x86_64 OS: Windows Status: NEW Severity: minor Priority: P1 Component: phobos Assignee: nob...@puremagic.com Reporter: r.97...@gmail.com import std.format; struct FormatSpecPrinter { void toString(scope void delegate(const(char)[]) sink, FormatSpec!char fmt) { sink.formattedWrite("%s", fmt); } } void main() { import std.stdio; "%(%(%s%)%)".writefln(FormatSpecPrinter()); // just fine. "%-(%-(%s%)%)".writefln(FormatSpecPrinter()); // dash is nicely handled. "%+(%(%s%)%)".writefln(FormatSpecPrinter()); // OK: plus flag for outer %(..%). "%(%+(%s%)%)".writefln(FormatSpecPrinter()); // inner plus flag crashes: first "%)" matches "%(" and the second "%)" left orphan. } Like in the example in the wiki article, I'd like to use '+' flag for another meaning, in a nested way. https://wiki.dlang.org/Defining_custom_print_format_specifiers So, I'd like '+' flags to be allowed both for outermost and nested '(' specifier. However, current implementation considers only "%-(" when looking for the matching "%)" of outer "%(". https://github.com/dlang/phobos/blob/f75eeb596d44544e98a23ee1fd0b60f9ae8b0956/std/format.d#L918 --