Description: "uint i = -1" is allowed by dmd 1.050. Expectation: A warning or an error should be shown by compiling the code. I misspelled int as uint. A boolean expression (if i < 0) always equals false. It took me long time to debug my code. Finally I have found out, that the value i is not -1.
I'll put this as an enhancement request because negate is currently an operation that is defined to work on unsigned values, hence no error.
This 'bug' is still around in D2. It looks like an heritage from C / C++, one of the bad kind. It allows you to write gems such as: ``` uint func (int i) { return i; } void main () { uint v = func(-42); } ``` @Walter: Would you be okay with the idea of deprecating this ? Related: https://issues.dlang.org/show_bug.cgi?id=259
That would make unsigned types way more sane to work with. And those who like -1 to be shortcut for "all 1's" could use ~0.
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18126 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB