www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8597] New: UFCS fails when used with a pointer to enum and implicit dereferencing

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

           Summary: UFCS fails when used with a pointer to enum and
                    implicit dereferencing
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: tommitissari hotmail.com


--- Comment #0 from Tommi <tommitissari hotmail.com> 2012-08-28 23:03:03 PDT ---
module main;

enum MyEnum { first, second, third }

MyEnum next(MyEnum myenum)
{
    return cast(MyEnum) (myenum + 1);
}

void main()
{
    auto myenum = MyEnum.second;
    auto ptrEnum = &myenum;

    auto maxEnum      =   ptrEnum.max;     // #0: OK
    auto nextExplicit = (*ptrEnum).next(); // #1: OK
    auto nextImplicit =   ptrEnum.next();  // #2
}

#2: Error: function main.next (MyEnum myenum) is not callable using argument
types (MyEnum*)

#2: Error: cannot implicitly convert expression (ptrEnum) of type MyEnum* to
MyEnum

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


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2013-01-25
16:22:11 PST ---
I think this is deliberate and it's unrelated to enums:

int ufcs(int i) { return 0; }
void main()
{
    auto i = 0;
    auto ptrInt = &i;
    auto a = ptrInt.ufcs();  // error
}

Same with structs.

There was a similar issue opened where someone made a rationale, it was about
not wanting to accidentally pass structs by value, or something like that. I'll
wait for someone to give a better response.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 25 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8597


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


--- Comment #2 from Kenji Hara <k.hara.pg gmail.com> 2013-04-24 00:34:21 PDT ---
 There was a similar issue opened where someone made a rationale, it was about
 not wanting to accidentally pass structs by value, or something like that. I'll
 wait for someone to give a better response.

Currently automatic pointer dereference is not supported in UFCS name look up. So this is an enhancement request. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Apr 24 2013