On 11.04.22 11:11, Salih Dincer wrote:
How is this possible? Why is it compiled? Don't the same names in the same scope conflict?

```d
int function(int) square;
void main()
{
   square = (int a) => a * a;
   int square = 5.square;
   assert(square == 25);
}
```

Thanks, SDB@79

- Local variables in a function can hide variables in less nested scopes. (Such hiding is only an error for nested block scopes within the same function.)

- UFCS always looks up names in module scope, it does not even check locals.
  • Lambdas Scope Salih Dincer via Digitalmars-d-learn
    • Re: Lambdas Scope user1234 via Digitalmars-d-learn
    • Re: Lambdas Scope Timon Gehr via Digitalmars-d-learn

Reply via email to