https://issues.dlang.org/show_bug.cgi?id=22480
Issue ID: 22480
Summary: Lack of template instantiation memoization for failed
templates
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
Example program:
struct T(uint x) {
pragma(msg, "Instantiated at ", x);
static assert(x == 0);
}
static assert(is(T!0));
static assert(is(T!0));
static assert(!is(T!1));
static assert(!is(T!1)); // redoes all the work :-(
prints:
Instantiated at 0u
Instantiated at 1u
Instantiated at 1u
Sometimes, detecting an error in template instantiation can be costly.
If the compiler memoized not only template instantiation successes but also
failures, it can save compilation time and improve output when pragma(msg, ...)
are involved.
--