www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 4253] New: opCall() not called in initialized struct

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4253

           Summary: opCall() not called in initialized struct
           Product: D
           Version: future
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This is a small C++ program that compiles:

template<typename T> struct Foo {
    Foo(T x) {}
    template<typename U> void operator()(U y) {}
};
int main() {
    Foo<int> foo(1);
    foo(1.5);
}


I think this is an equivalent D2 program:

struct Foo(T) {
    this(T x) {}
    void opCall(U)(U y) {}
}
void main() {
    auto foo = Foo!int(1);
    foo(1.5); // line 7
}


But DMD V. 2.046 prints:
temp.d(7): Error: constructor temp.Foo!(int).Foo.this (int x) is not callable
using argument types (double)
temp.d(7): Error: cannot implicitly convert expression (1.5) of type double to
int

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 30 2010
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4253




A simpler test case:

struct Foo {
    this(int x) {}
    void opCall(double y) {}
}
void main() {
    Foo foo = Foo(1);
    foo(1.5);
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 30 2010
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4253




See also bug 4053

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Mar 08 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=4253


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |k.hara.pg gmail.com
         Resolution|                            |DUPLICATE



*** This issue has been marked as a duplicate of issue 6036 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 21 2011