Thread overview
[Issue 21258] Tuple parameters with defaults use the first tuple element for all defaults since 2.094.0-beta.1
Sep 17, 2020
Richard Manthorpe
Sep 17, 2020
Richard Manthorpe
Sep 17, 2020
Dlang Bot
Sep 18, 2020
Dlang Bot
Sep 26, 2020
Dlang Bot
September 17, 2020
https://issues.dlang.org/show_bug.cgi?id=21258

Richard Manthorpe <rmanth@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|tuple default parameters    |Tuple parameters with
                   |                            |defaults use the first
                   |                            |tuple element for all
                   |                            |defaults since
                   |                            |2.094.0-beta.1

--
September 17, 2020
https://issues.dlang.org/show_bug.cgi?id=21258

--- Comment #1 from Richard Manthorpe <rmanth@gmail.com> ---
It's even more fun if you try it with different types:

alias AliasSeq(TList...) = TList;

auto foo(AliasSeq!(int, string) args = AliasSeq!(3, "hello"))
{
    return args[0] * args[1].length;
}

static assert(foo() == 15); // Error: cannot implicitly convert expression 3 of
type int to string

--
September 17, 2020
https://issues.dlang.org/show_bug.cgi?id=21258

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull

--- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> ---
@Geod24 created dlang/dmd pull request #11749 "Fix 21258 - Tuple parameters use the first element of a default tuple value" fixing this issue:

- Fix 21258 - Tuple parameters use the first element of a default tuple value

  A single character sometimes means the world.

https://github.com/dlang/dmd/pull/11749

--
September 18, 2020
https://issues.dlang.org/show_bug.cgi?id=21258

Dlang Bot <dlang-bot@dlang.rocks> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #11749 "Fix 21258 - Tuple parameters use the first element of a default tuple value" was merged into stable:

- 8d3fe8fe5bf12a4bf493ddcd78bc4f6a82118784 by Geod24:
  Fix 21258 - Tuple parameters use the first element of a default tuple value

  The logic tried to use a single variable for both keeping track of the
  original index and the extended index, but actually only tracked the
  extended index.
  Since `if (tupleStartIdx < eidx) tupleStartIdx = eidx` would be true
  for every iteration, we would always assign the value at index 0.

https://github.com/dlang/dmd/pull/11749

--
September 26, 2020
https://issues.dlang.org/show_bug.cgi?id=21258

--- Comment #4 from Dlang Bot <dlang-bot@dlang.rocks> ---
dlang/dmd pull request #11793 "merge stable" was merged into master:

- e0a9304324b7d1d2fcf9662c2f77b5c42e804b05 by Geod24:
  Fix 21258 - Tuple parameters use the first element of a default tuple value

  The logic tried to use a single variable for both keeping track of the
  original index and the extended index, but actually only tracked the
  extended index.
  Since `if (tupleStartIdx < eidx) tupleStartIdx = eidx` would be true
  for every iteration, we would always assign the value at index 0.

https://github.com/dlang/dmd/pull/11793

--