[Issue 22327] [Templates] arguments of T[] literals work for exactly one initialization before being set in stone

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Nov 4 22:57:51 UTC 2021


https://issues.dlang.org/show_bug.cgi?id=22327

--- Comment #4 from Paul Backus <snarwin+bugzilla at gmail.com> ---
Example program (simplified from attached "minimized" example):

---
template foo(T, T[] somedata_) {}

alias bar = foo!(int, [1, 2, 3]);
alias faz = foo!(string, ["a", "b", "c"]);
---

Expected behavior: compiles successfully.

Actual behavior: fails to compile, with the following error message:

---
Error: template instance `foo!(string, ["a", "b", "c"])` does not match
template declaration `foo(T, int[] somedata_)`
---

Removing the line `alias bar = foo!(int, [1, 2, 3]);` causes compilation to
succeed.

--


More information about the Digitalmars-d-bugs mailing list