www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11312] New: Avoid auto-dereference for UFCS functions

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

           Summary: Avoid auto-dereference for UFCS functions
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com



03:10:05 PDT ---
Here's an example of UFCS with a simple int*:

-----
int* getPtr() { return null; }
int getValue(int*) { return 0; }

void main()
{
    int* op = getPtr();
    int x = op.getValue();  // works ok
}
-----

Now the following is an example of where you're interfacing with some C code,
and you want to allow UFCS-style syntax to make it easier to use the C library.
The C library defines opaque struct types and only allows manipulation through
pointers and functions:

-----
struct Struct;
extern(C) Struct* getStruct() { return null; }
extern(C) int getValue(Struct*) { return 0; }

void main()
{
    Struct* op = getStruct();
    int x = op.getValue();  // error
}
-----

This errors with:
test.d(10): Error: struct Struct is forward referenced

I think this might just be a compiler bug. There's no point in dereferencing
the pointer here because the function call would not match (getValue is typed
as Struct*, not Struct).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 21 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=11312




03:20:06 PDT ---
Update: The code used to work in 2.062, but fails to work since 2.063.2. Is
this a regression?

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