www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Bug?

reply JG <someone somewhere.com> writes:
Hi,

Is this a bug?
```d
import std;

template test(alias f) {

     auto test(I)(I i) { return f(i); }
}

void main()
{
     alias t = test!(x=>x+1);
     1.t.writeln; //<--Doesn't compile
     1.test!(x=>x+1).writeln;
     t(1).writeln;
}
```
Jun 14 2022
parent reply Steven Schveighoffer <schveiguy gmail.com> writes:
On 6/14/22 3:35 PM, JG wrote:
 Hi,
 
 Is this a bug?
 ```d
 import std;
 
 template test(alias f) {
 
      auto test(I)(I i) { return f(i); }
 }
 
 void main()
 {
      alias t = test!(x=>x+1);
      1.t.writeln; //<--Doesn't compile
      1.test!(x=>x+1).writeln;
      t(1).writeln;
 }
 ```
Not a bug. Local symbols can't be used as UFCS functions. -Steve
Jun 14 2022
parent JG <someone somewhere.com> writes:
On Tuesday, 14 June 2022 at 19:49:39 UTC, Steven Schveighoffer 
wrote:
 On 6/14/22 3:35 PM, JG wrote:
 Hi,
 
 Is this a bug?
 ```d
 import std;
 
 template test(alias f) {
 
      auto test(I)(I i) { return f(i); }
 }
 
 void main()
 {
      alias t = test!(x=>x+1);
      1.t.writeln; //<--Doesn't compile
      1.test!(x=>x+1).writeln;
      t(1).writeln;
 }
 ```
Not a bug. Local symbols can't be used as UFCS functions. -Steve
Thanks very much. I left wondering why that design decision was made.
Jun 14 2022