[Issue 1649] Variant coercion fails with delegates
Christopher Wright
dhasenan at gmail.com
Sun Nov 25 05:49:09 PST 2007
Brad Roberts wrote:
> http://www.dsource.org/projects/phobos/browser/candidate/phobos/std/variant.d?rev=511
>
> Why static assert(false) rather than return false?
Coerce doesn't allow that. Besides which, it's better to fail early --
if Variant doesn't support that operation, it shouldn't compile, since
it'll ALWAYS fail at runtime. And if the user wants something like that,
they'll just put assert(false) in their code.
> Additionally, if
> you're going to static assert(false), then a message ought to be included
> since it's going to result in a nice meaningless compilation failure.
>
> Additionally.. add a code block -> add a unit test!
We can actually do that now, using __traits(compiles).
unittest {
Variant v = 5;
assert (!__traits(compiles, v.coerce!(bool delegate())));
}
> Lastly, stop doing trivial bug fixes on the candidate branch. They belong
> directly on the trunk.
More information about the Digitalmars-d-bugs
mailing list