Bug 19093 – 'cannot alias itself' when using a template instantiation in a template parameter

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-07-18T11:32:20Z
Last change time
2024-12-13T18:59:36Z
Keywords
rejects-valid
Assigned to
No Owner
Creator
Simen Kjaeraas
Moved to GitHub: dmd#19457 →

Comments

Comment #0 by simen.kjaras — 2018-07-18T11:32:20Z
alias Foo(T) = T; struct Test(T, Foo!T t) {} unittest { Test!(int, 3) a; } foo.d(2): Error: alias T = T; cannot alias itself, use a qualified name to create an overload set
Comment #1 by b2.temp — 2020-07-04T19:01:08Z
This is more a bad diagnostic. The real problem being that the previous template params cannot be reused, e.g --- alias Foo(T) = T; struct Test(T, Foo!(T[]) t) {} void main() { Test!(int, [3]) a; } ---
Comment #2 by simen.kjaras — 2020-07-05T15:30:15Z
Works better if Foo's parameter is called something else: alias Foo(U) = U; // undefined identifier T Obviously you're right about the real problem, and the error message is a case of bad diagnostic. However, I think you should be allowed to reuse the previous template params.
Comment #3 by robert.schadek — 2024-12-13T18:59:36Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/19457 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB