Bug 12466 – Template type parameter should not require a new symbol for deducing a type

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-25T09:55:29Z
Last change time
2022-07-06T05:24:59Z
Assigned to
No Owner
Creator
Andrej Mitrovic

Comments

Comment #0 by andrej.mitrovich — 2014-03-25T09:55:29Z
----- void foo(Array : C[N], C, size_t N)(Array array) { } void bar(C[N], C, size_t N)(C[N] array) { } // NG void main() { char[2] arr; foo(arr); // ok bar(arr); // NG in declaration } ----- $ dmd test.d > Error: identifier expected for template value parameter This is a little bit inconsistent with how is() already works. The following is currently allowed: ----- void main() { char[2] arr; { // ok static if (is(typeof(arr) Array : A[N], A, size_t N)) { pragma(msg, Array); // char[2] } } { // also ok static if (is(typeof(arr) /* Array */: A[N], A, size_t N)) { pragma(msg, A[N]); // char[2] } } } ----- Therefore I think we should also allow it in a template (function) declaration as well.
Comment #1 by andrej.mitrovich — 2022-07-06T05:24:59Z
I think this is incorrect. The first version is what's documented as required in order to make it possible to derive those types. The second version in 'bar' would require a DIP.