Request: When static assert fails, display original instantiation line
Don Clugston
dac at nospam.com.au
Wed Nov 22 23:57:19 PST 2006
Using the "sudden-death" static asserts, template libraries can now
generate very high-quality error messages (in contrast to the garbage
you usually get in C++). There's a problem, though: "sudden-death"
static asserts is that they only tell you the line where the static
assert is, but they normally refer to a problem where the template was
instantiated from.
So we get error messages like:
library.d(375): (num<50), Number is too big
This has been adequate for library developers, but is unusable for
library users. We don't need a full template trace, just the original
file and line where the first template instantiation or mixin was done
from. Something like:
myproject.d(20): caused static assert in:
library.d(375): (num<50) is false, Number is too big
Or:...
library.d(375): (num<50) is false, Number is too big
myproject.d(20): ultimately instantiated from here.
Coupled with Oskar's recent request for a flag to re-enable template
backtrace (maybe -nogag or -backtrace) for library developers, I think
this would completely solve the template error message problem.
More information about the Digitalmars-d
mailing list