Bug 20576 – TemplateTypeParameter and TemplateValueParameter default values are not checked
Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2020-02-11T22:29:20Z
Last change time
2022-01-28T09:56:18Z
Keywords
accepts-invalid
Assigned to
No Owner
Creator
Basile-z
Comments
Comment #0 by b2.temp — 2020-02-11T22:29:20Z
The following code should not compile
---
void foo(T : Object = INVALID)(T t)
{
}
void main()
{
foo(null);
}
---
because INVALID does not give a valid symbol, although it is not used in the call.
Comment #2 by pro.mathias.lang — 2020-02-12T00:22:21Z
I'm not sure that's an issue.
In trivial cases like this the code is obviously wrong, but the only way we're going to realistically catch all these is by always instantiating the template with default parameters, which is 1) not always possible, 2) a waste of compilation time.
Comment #3 by b2.temp — 2020-02-12T01:53:41Z
I agree about the waste of time but keep the issue opened, just to be clear on the fact that the problem is already known.