Thread overview
[Issue 15781] [REG2.069] Template type deduction failure with same-type variables with different constness
[Issue 15781] Template type deduction failure with same-type variables with different constness
Mar 09, 2016
Johan Engelen
Mar 09, 2016
Daniel Kozak
Mar 11, 2016
Kenji Hara
Mar 15, 2016
Kenji Hara
Mar 15, 2016
Kenji Hara
March 09, 2016
https://issues.dlang.org/show_bug.cgi?id=15781

Johan Engelen <jbc.engelen@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|Type deduction const        |Template type deduction
                   |                            |failure with same-type
                   |                            |variables with different
                   |                            |constness

--
March 09, 2016
https://issues.dlang.org/show_bug.cgi?id=15781

Daniel Kozak <kozzi11@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kozzi11@gmail.com

--
March 11, 2016
https://issues.dlang.org/show_bug.cgi?id=15781

--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> ---
Introduced in: https://github.com/D-Programming-Language/dmd/pull/4818

--
March 15, 2016
https://issues.dlang.org/show_bug.cgi?id=15781

Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |rejects-valid
            Summary|Template type deduction     |[REG2.069] Template type
                   |failure with same-type      |deduction failure with
                   |variables with different    |same-type variables with
                   |constness                   |different constness

--- Comment #2 from Kenji Hara <k.hara.pg@gmail.com> ---
(In reply to Johan Engelen from comment #0)
> The code compiles fine with DMD 2.068.2.
> The code fails to compile with DMD 2.068.2 and DMD 2.070.2:
> deduce.d(19): Error: template deduce.foo cannot deduce function from
> argument types !()(const(TypeA), TypeA), candidates are:
> deduce.d(5):        deduce.foo(T)(T start, T end)
> 
> I believe this is a regression.
> DMD 2.068.2 deduces T = TypeA (non-const).

This is a rejects-valid issue from 2.069, so is a regression. But, the behavior in 2.068 -- T is deduced to TypeA (non-const) -- is not intentional result, because there was order-dependent bug.

struct S
{
    int value;
}

void foo(T)(T a, T b)
{
    pragma(msg, T);
}

void main()
{
    const S cs;
          S ms;
    foo(cs, ms);    // prints 'S'
    foo(ms, cs);    // prints 'const(S)', inconsistent!
}

Therefore, from the built-in common type calculation mechanism, the T should be deduced to const(S) independent from the order of function arguments.

--
March 15, 2016
https://issues.dlang.org/show_bug.cgi?id=15781

Kenji Hara <k.hara.pg@gmail.com> changed:

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

--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> ---
https://github.com/D-Programming-Language/dmd/pull/5531

--
March 19, 2016
https://issues.dlang.org/show_bug.cgi?id=15781

--- Comment #4 from github-bugzilla@puremagic.com ---
Commits pushed to stable at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/db7e4e1136a0c4cd1c0e310b0fdbc1984894719f
fix Issue 15781 - Template type deduction failure with same-type variables with
different constness

https://github.com/D-Programming-Language/dmd/commit/cd8e31700a0f97a073087eac4eaf9d58b7f59a7a Merge pull request #5531 from 9rnsr/fix15781

[REG2.069] Issue 15781 - Template type deduction failure with same-type variables with different constness

--
March 19, 2016
https://issues.dlang.org/show_bug.cgi?id=15781

github-bugzilla@puremagic.com changed:

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

--
March 19, 2016
https://issues.dlang.org/show_bug.cgi?id=15781

--- Comment #5 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/db7e4e1136a0c4cd1c0e310b0fdbc1984894719f
fix Issue 15781 - Template type deduction failure with same-type variables with
different constness

https://github.com/D-Programming-Language/dmd/commit/cd8e31700a0f97a073087eac4eaf9d58b7f59a7a Merge pull request #5531 from 9rnsr/fix15781

--