www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21258] New: tuple default parameters

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

          Issue ID: 21258
           Summary: tuple default parameters
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: rmanth gmail.com

alias AliasSeq(TList...) = TList;

int foo(AliasSeq!(int, int) args = AliasSeq!(3, 5))
{
    return args[0] * args[1];
}

static assert(foo(2) == 10); // fails in 2.094.0-beta.1
static assert(foo() == 15); // fails in 2.094.0-beta.1


This used to give defaults of 3 and 5 but now gives defaults of 3 and 3 as of
2.094.0-beta.1. More generally any tuple parameter with tuple defaults just
tries to apply the first default value to all arguments.

Looks like it was broken by https://github.com/dlang/dmd/pull/11564

--
Sep 17 2020