Bug 23118 – UFCS not working for function level templates
Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2022-05-17T10:54:17Z
Last change time
2022-05-17T11:03:39Z
Assigned to
No Owner
Creator
RazvanN
Comments
Comment #0 by razvan.nitu1305 — 2022-05-17T10:54:17Z
This code fails:
```
void main()
{
static void func(T)(T a, T b) { }
2.func!int(2); // Error: no property `func` for type `int`
}
```
whereas this code compiles fine:
```
static void func(T)(T a, T b) { }
void main()
{
2.func!int(2);
}
```
I haven't found anything in the spec about this case, but I don't see why ufcs would not be considered in the former case.
Comment #1 by dkorpel — 2022-05-17T11:01:11Z
This is intentionally disallowed, though it is sometimes requested as an improvement.
https://dlang.org/spec/function.html#pseudo-member
> Functions declared in a local scope are not found when searching for a matching UFCS function.
Comment #2 by razvan.nitu1305 — 2022-05-17T11:02:21Z