Bug?

Simen Kjærås simen.kjaras at gmail.com
Mon May 11 13:12:37 UTC 2020


On Monday, 11 May 2020 at 12:44:45 UTC, Jack Applegame wrote:
> On Monday, 11 May 2020 at 12:30:22 UTC, Adam D. Ruppe wrote:
>> UFCS is only defined to work with global scope functions. A 
>> restricted import (module : symbol, symbols) puts things in 
>> local scope so ufcs doesn't apply.
>
> But in this case the error should be displayed for lines 4 and 
> 5, not 11.
> Line 11 contains a call to a member function, not UFCS.
>
> In addition, if you add the parentheses, then it works:
> assert(rng.front() == '1');

You're right, and it absolutely seems the call on lines 4 and 5 
work correctly. Instead, the compiler is confused by the presence 
of two different overloads for front in Range!T, and doesn't 
attempt to call the one it can call. We get the exact same 
behavior here:

struct S {
     int gun()(int i) { return 0; }
     alias fun = gun;
     int fun() { return 1; }
}

static assert(S().fun == 1);

Filed here: https://issues.dlang.org/show_bug.cgi?id=20821

--
   Simen


More information about the Digitalmars-d-learn mailing list