www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15416] New: UFCS does not attempt to derefence (but should it?)

https://issues.dlang.org/show_bug.cgi?id=15416

          Issue ID: 15416
           Summary: UFCS does not attempt to derefence (but should it?)
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: minor
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: lt.infiltrator gmail.com

========================
class C { int x; void bar() { } }
void foo(C) { }

void main() {
    auto c = new C;
    auto d = &c;
    d.bar; // d.bar (C*) does multiple derefs to c.bar (C)
    d.foo; // d.foo does not attempt to deref d (C*) to c (C)
}
========================
/d690/f182.d(8): Error: function f182.foo (C _param_0) is not callable using
argument types (C*)
========================


This leads to inconsistent behaviour between UFCS functions and true methods. 
However, should this behaviour be changed for UFCS functions?  If it's not
extended to non-UFCS functions, it will lead to inconsistent behaviour again
(d.foo would work but foo(d) would not).

But if it's extended to all functions, this could get messy for all other
functions.

--
Dec 07 2015