[Issue 23779] New: UFCS using pointer should be allowed and should automatically take a reference on values

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Mar 14 14:52:21 UTC 2023


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

          Issue ID: 23779
           Summary: UFCS using pointer should be allowed and should
                    automatically take a reference on values
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: ryuukk.dev at gmail.com

This code:

```
struct Data
{
    int value;
}

void something(Data* data)
{
    data.value++;
}

void main()
{
    Data d;
    Data* ptr = &d;

    ptr.something();  // works
    (&d).something(); // works, but the syntax looks bad
    d.something();    // doesn't work, compiler should do what i do above and
allow it
}
```

It is similar to the request here:
https://issues.dlang.org/show_bug.cgi?id=8597

But  it's the opposite, if the function is declared by accepting a pointer,
then this example should be allowed

--


More information about the Digitalmars-d-bugs mailing list