Bug 11312 – [REG2.063] Avoid auto-dereference for UFCS functions
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-21T03:10:00Z
Last change time
2014-08-28T04:10:20Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2013-10-21T03:10:05Z
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).
Comment #1 by andrej.mitrovich — 2013-10-21T03:20:06Z
Update: The code used to work in 2.062, but fails to work since 2.063.2. Is this a regression?
(In reply to Andrej Mitrovic from comment #1)
> Update: The code used to work in 2.062, but fails to work since 2.063.2. Is
> this a regression?
I confirmed that is a regression.
Comment #5 by github-bugzilla — 2014-08-28T04:10:20Z