On Monday, 4 January 2021 at 12:35:12 UTC, John Colvin wrote:
On Monday, 4 January 2021 at 09:21:02 UTC, Ola Fosheim Grøstad
wrote:
On Monday, 4 January 2021 at 09:18:50 UTC, Ola Fosheim Grøstad
wrote:
On Monday, 4 January 2021 at 05:55:37 UTC, Ola Fosheim
Grostad wrote:
On Monday, 4 January 2021 at 04:37:22 UTC, 9il wrote:
[...]
But it is a bug even if there was no C++... An alias should
work by simple substitution, if it does not, then it is no
alias...
Here is an even simpler example that does not work:
struct Foo(T){}
void foo(T)(T!int x) {}
alias FooInt = Foo!int;
void main() {
foo(FooInt());
}
Oh, now wait, it does:
struct Foo(T){}
void foo(alias T)(T!int x) {}
alias FooInt = Foo!int;
void main() {
foo(FooInt());
}
My mistake.
What's the simplest example that doesn't work and is that
simple example just indirection through an alias or is it
actually indirection through a template that *when
instantiated* turns out to be just an alias?
I have a suspicion that what you're asking for here is the
type-inference to have x-ray vision in to uninstantiated
templates that works for a few simple cases. Am I wrong?
To be clear, a really useful special case can be really useful
and worthwhile, but I'm not convinced this is the principled
"type system bug" you are saying it is.
I don't have time to post an example, but x-ray vision is far
from what is asked for, just following basic rules established in
type system theory decades ago.
In practice I've had many instances where TypeScript would
correctly perform generic type unification while dmd gives up at
the first bump in the road.