[Issue 10018] Value range propagation for immutable variables
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Fri Jun 27 21:40:20 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=10018
Lionello Lunesu <lio+bugzilla at lunesu.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|WORKSFORME |---
--- Comment #9 from Lionello Lunesu <lio+bugzilla at lunesu.com> ---
(In reply to yebblies from comment #7)
> This seems to work just fine:
>
> void main()
> {
> immutable int i = 1;
> byte x = i;
> }
This works now because a call to optimize() will remove the reference to 'i'
and replace it with the constant expression. If it's not a constant expression
(for example, ?: not known at compile time) then it won't propagate the range.
--
More information about the Digitalmars-d-bugs
mailing list