[Issue 13228] Value range analysis for the length of slices

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Nov 11 14:12:00 PST 2014


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

--- Comment #4 from bearophile_hugs at eml.cc ---
(In reply to Steven Schveighoffer from comment #3)

> This is not the same, because a's value isn't known at compile time, just its range.

You are probably right, that example seems bad. Sorry, and thank you for
spotting the problem.


> This ER is asking for flow analysis, which I think is not on the table.

According to Walter flow analysis is on the table for the future of D. But this
ER doesn't want to ask for flow flow analysis (it's meant to work similarly to
the current value range analysis. See also below). If this ER seems to ask for
flow analysis then I have done a mistake in an example, or I have confused
ideas :-)


> Value range analysis for expressions dies at the end of an expression.

This is not longer true, this compiles:

uint x = 10;
void main() {
    immutable uint y = x % 100;
    ubyte z = y; // No errors here.
}


Now the value range of run-time immutable values is carried beyond the end of
an expression.

--


More information about the Digitalmars-d-bugs mailing list