[Issue 19775] New: multiple argument string mixin doesn't expand tuples

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Mar 30 08:11:34 UTC 2019


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

          Issue ID: 19775
           Summary: multiple argument string mixin doesn't expand tuples
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody at puremagic.com
          Reporter: b2.temp at gmx.com

Splitted from 19442

passing a template parameter list does not expand the arguments:

enum x1 = 1;
enum makeIdent(args...) = mixin(args);
pragma(msg, makeIdent!("x", 1)); // Error: undefined identifier `tuple`

// Using this works but only for two arguments
enum makeIdent(args...) = mixin(args[0], args[1]);
pragma(msg, makeIdent!("x", 1)); // Output: 1

Here's the real code I was working on (like compile-time std.conv.text but
probably more efficient):

enum ctText(args...) = mixin("`", args, "`");
pragma(msg, ctText!(5, " bottles")); // Output: tuple(5, " bottles")

Above, args is not implicitly expanded.

// This works but only for two arguments
enum ctText(args...) = mixin("`", args[0], args[1], "`");
static assert(ctText!(5, " bottles") == "5 bottles");

--


More information about the Digitalmars-d-bugs mailing list