Bug 6661 – Templates instantiated only through is(typeof()) shouldn't cause errors
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2011-09-13T02:44:00Z
Last change time
2015-06-09T05:10:45Z
Assigned to
nobody
Creator
clugdbug
Comments
Comment #0 by clugdbug — 2011-09-13T02:44:40Z
The template blaz!int cannot be instantiated without errors, because it contains an assignment of a string literal to int. But, since it is not actually instantiated, it shouldn't cause a compile error.
template blaz(Q)
{
int qutz(Q y)
{
Q q = "abc";
return 67;
}
static assert(qutz(13).sizeof!=299);
const Q blaz = 6;
}
static assert(is(typeof(blaz!(int).blaz)));
*** Issue 6262 has been marked as a duplicate of this issue. ***
Comment #6 by github-bugzilla — 2013-01-24T14:27:48Z
Commit pushed to master at https://github.com/D-Programming-Language/dmdhttps://github.com/D-Programming-Language/dmd/commit/e9142862884625d0db801bbf1f05ad9487aae28b
fix test result for issue 6661
Inherently, when you try to instantiate a template, the whole template
body correctness should be checked at the same time.
In this case, bug6661!(int).qutz is a normal function declared inside
template, so it should be instantiated at the same time with bug6661!(int).
Now, the inner `static assert(qutz(13).sizeof!=299);` runs the semantic3
of qutz by calling it. So the module level static assertion fails _correctly_.
But, `is(typeof(bug6661x!(int)))` still returns true incorrectly.
I think it is yet another known issue in current dmd implementation.