February 28, 2015
https://issues.dlang.org/show_bug.cgi?id=13010

bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc

--- Comment #9 from bearophile_hugs@eml.cc ---
(In reply to Lionello Lunesu from comment #8)

This doesn't compile:

ubyte x;
void main() {
    immutable int y = x;
    ubyte z = y;
    static assert(y >= 0);
}


But this compiles, so the compiler knows statically y can't be negative:

ubyte x;
void main() {
    immutable int y = x;
    ubyte z = y;
}

So accepting that static assert seems a small improvement, perhaps it's just a matter of using the variable range knowledge inside static assert.

--
February 28, 2015
https://issues.dlang.org/show_bug.cgi?id=13010

--- Comment #11 from bearophile_hugs@eml.cc ---
Even this doesn't compile, but it should:

void main() {
    ubyte x;
    static assert(x >= 0);
}

--
February 28, 2015
https://issues.dlang.org/show_bug.cgi?id=13010

--- Comment #10 from David Nadlinger <code@klickverbot.at> ---
(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.

--
February 28, 2015
https://issues.dlang.org/show_bug.cgi?id=13010

--- Comment #12 from Lionello Lunesu <lio+bugzilla@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);

--
February 28, 2015
https://issues.dlang.org/show_bug.cgi?id=13010

--- Comment #13 from bearophile_hugs@eml.cc ---
(In reply to Lionello Lunesu from comment #12)

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


I don't understand the point of this code.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=13010

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

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

--- Comment #14 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/18844

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--
1 2
Next ›   Last »