Comment #0 by dlang-bugzilla — 2023-05-12T16:43:47Z
//////////////////////////// test.d ///////////////////////////
template T(bool value) {}
@property bool getValue() { return true; }
alias Inst1 = T!(getValue); // OK
struct S2 { static @property bool getValue() { return true; } }
alias Inst2 = T!(S2.getValue); // OK
struct S3 { @property bool getValue() { return true; } }
alias Inst = T!(S3().getValue); // Error
///////////////////////////////////////////////////////////////
For some reason, free functions and static functions work, but not instance methods.
Compiler says:
test.d(10): Error: template instance `T!(getValue)` does not match template declaration `T(bool value)`
test.d(10): `getValue` is not of a value of type `bool`
Comment #1 by razvan.nitu1305 — 2023-05-16T11:38:26Z
This doesn't seem to have anything to do with property. This yields the same result:
```
template T(bool value) {}
bool getValue() { return true; }
alias Inst1 = T!(getValue); // OK
struct S2 { static bool getValue() { return true; } }
alias Inst2 = T!(S2.getValue); // OK
struct S3 { bool getValue() { return true; } }
alias Inst = T!(S3().getValue); // Error
```
Comment #2 by razvan.nitu1305 — 2023-05-16T13:01:38Z
I've tried to entangle what happens here, but the behavior is a bit puzzling. It turns out that free functions and static member functions are considered types when instantiating the template, but the `S3().getValue` is considered an expression. On the expression path of the code, since the () are missing, this is seen as just refering to the symbol `getValue` not actually calling it. Resolving `getValue` to a function fixes the issue but it makes other parts of the template instantiation mechanism fail, so I'm stuck at this point. There's just too much context that I'm missing: I have no idea why `S2.getValue` or `getValue` are treated as types in this scenario. They must be resolved somehow later to their corresponding expressions.
Comment #3 by robert.schadek — 2024-12-13T19:28:50Z