www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17177] New: AutoImplement fails on function overload sets

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

          Issue ID: 17177
           Summary: AutoImplement fails on function overload sets with
                    "cannot infer type from overloaded function symbol"
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: alexandru.ermicioi gmail.com

Given following code:

import std.meta;
import std.typecons;
import std.traits;

class ProxyablePerson {
    private {
        string surname_;
    }

    public  {
        int surname(string surname) {
            return 0;
        }

        int surname() {
            return 0;
        }
    }
}

string how(C, alias fun)() {
    string stmt;

    static if (!is(ReturnType!fun == void)) {
        stmt ~= "
            return parent(args);
        ";
    } else {
        stmt ~= "
            parent(args);
        ";
    }

    return stmt;
}
alias Proxy = AutoImplement!(ProxyablePerson, how,
templateNot!isFinalFunction);

void main() {

}

AutoImplement fails on surname overload set with following error:
/usr/include/dmd/phobos/std/typecons.d-mixin-3579(3584,15): Error: cannot infer
type from overloaded function symbol &super.surname
/usr/include/dmd/phobos/std/typecons.d-mixin-3579(3592,15): Error: cannot infer
type from overloaded function symbol &super.surname
src/app.d(36,15): Error: template instance
std.typecons.AutoImplement!(ProxyablePerson, how, templateNot) error
instantiating

Note: leaving one function from overload set (so no surname overload set is
present), will compile ok without any error.

--
Feb 12