[Issue 13010] Use variable range propagation (VRP) for static assert
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jun 30 10:02:52 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13010
--- Comment #3 from Lionello Lunesu <lio+bugzilla at lunesu.com> ---
(In reply to Kenji Hara from comment #2)
> (In reply to Lionello Lunesu from comment #0)
> > This code should work:
> >
> > void testvrp(ubyte l)
> > {
> > immutable int i = l;
> > static assert(i + 1);
> > }
>
> To me the code looks very weird, because:
>
> 1. static assert condition is *always* evaluated in compile time.
> 2. but the expression i + 1 cannot be evaluated at compile time.
>
> These items are contradict each other, so I think it should not be compiled.
>
> Could you please show me an *actual* use case of this enhancement?
How do you feel about it when the code is changed to this:
void testvrp(ubyte l)
{
immutable int i = l;
static assert(i >= 0);
}
--
More information about the Digitalmars-d-bugs
mailing list