www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8677] New: compiler attempts to call ctor instead of opCall

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

           Summary: compiler attempts to call ctor instead of opCall
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



07:31:40 PDT ---
struct Foo
{
    this(int) {}

    bool opCall(string)
    {
        return true;
    }
}

void main()
{
    Foo foo = Foo(1);
    if (foo("a")) { }  // error
}

test.d(17): Error: constructor test.Foo.this (int _param_0) is not callable
using argument types (string)
test.d(17): Error: cannot implicitly convert expression ("a") of type string to
int

The compiler has no business calling a ctor on a variable invocation.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 17 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8677


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc



Probably this is a dupe.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 17 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8677


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

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



10:49:43 PDT ---
Yep, almost exact dup of http://d.puremagic.com/issues/show_bug.cgi?id=7210#c1

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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 17 2012