Bug 2303 – static assert in a template function is not reported

Status
RESOLVED
Resolution
WORKSFORME
Severity
major
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2008-08-22T02:53:00Z
Last change time
2015-06-09T01:20:08Z
Assigned to
bugzilla
Creator
samukha

Comments

Comment #0 by samukha — 2008-08-22T02:53:16Z
I wasn't able to reduce this further. Must be related to 2227 T foo(T : S!(U), U)(invariant(U) u) { T s; bar!(T)(s, u); return s; } void bar(T : S!(U), U)(T s, invariant(U) u) { static assert(false, "Error!"); // compiles if this line is commented out } void main() { foo!(S!(int))(1); } ---- : template Test.bar(T) does not match any function template declaration : template Test.bar(T) cannot deduce template function from argument types !(S!(int))(S!(int),invariant(int)) : template instance Test.foo!(S!(int),int) error instantiating This should report the static assert message, preferably with template instantiation trace.
Comment #1 by samukha — 2008-08-22T03:01:54Z
A corrected example: ---- struct S(T) { } void foo(T : S!(U), U)(invariant(U) u) { T s; bar!(T)(s, u); } void bar(T : S!(U), U)(T s, invariant(U) u) { static assert(false, "Error!"); } void main() { foo!(S!(int))(1); } ---- Works as expected if invariant type modifiers are omitted.
Comment #2 by bugzilla — 2008-08-26T03:44:17Z
The second, corrected example produces the following when compiled with 2.018, both with and without the invariant type modifiers: test.d(13): static assert "Error!" which appears to be correct.
Comment #3 by samukha — 2008-08-26T08:14:15Z
My apologies. This bug disappeared at some point after dmd 2.015