www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22208] New: [REG 2.067] Overload resolution fails to bind


          Issue ID: 22208
           Summary: [REG 2.067] Overload resolution fails to bind
                    immutable class-valued AA to inout parameter of
                    template function
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla gmail.com

As of DMD 2.097.0, the following program fails to compile:

class Style {}

immutable Style[int] gluiDefaultTheme;

void makeTheme()() {}

void makeTheme()(inout(Style[int]) parent) {}

void main()

The error message is:

onlineapp.d(11): Error: template `onlineapp.makeTheme` cannot deduce function
from argument types `!()(immutable(Style[int]))`, candidates are:
onlineapp.d(5):        `makeTheme()()`
onlineapp.d(7):        `makeTheme()(inout(Style[int]) parent)`

Making any of the following changes causes the program to compile successfully:

* Changing Style from a class to a struct.
* Changing gluiDefaultTheme from immutable to mutable.
* Changing the type of gluiDefaultTheme from Style[int] to Style[].
* Removing the empty template parameter lists from makeTheme's overloads and
removing the empty template argument list from the call in main.

According to run.dlang.io, this program:

* Failed to compile prior to DMD 2.065.0
* Compiled successfully with DMD 2.065.0 and 2.066.0
* Failed to compile again starting with DMD 2.067.1

So, this is a regression introduced in DMD 2.067.

Aug 13