[Issue 13010] Use variable range propagation (VRP) for static assert

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Feb 28 07:12:28 PST 2015


https://issues.dlang.org/show_bug.cgi?id=13010

--- Comment #12 from Lionello Lunesu <lio+bugzilla at lunesu.com> ---
(In reply to David Nadlinger from comment #10)
> (In reply to Lionello Lunesu from comment #8)
> > (In reply to David Nadlinger from comment #7)
> > > I'm not sure whether this is worth the added language complexity. Do you
> > > have an example for a compelling use case?
> > 
> > Statically testing the range of a variable:
> > 
> > ubyte u;
> > static assert(u >= 0);
> 
> 1. That's hardly what I'd call a use case. It's a minimal snippet showing a
> consequence of the feature, but doesn't tell me why I would ever want to do
> this in the first place.
> 
> 2. In this specific case, inspecting the type (isUnsigned) would be enough
> anyway.

Fine:

ubyte u;
//<a lot of code>
static assert(u < 9);

--


More information about the Digitalmars-d-bugs mailing list