Operator declaration

Nick Treleaven nick at geany.org
Sun May 31 15:42:32 UTC 2026


On Sunday, 31 May 2026 at 08:54:39 UTC, Dom Disc wrote:
> On Friday, 29 May 2026 at 10:56:51 UTC, Nick Treleaven wrote:
>> Can you give an example of what you think should work but 
>> doesn't?
>
> ```d
> byte x = 7;
> x = -x;  // cannot convert -x of type int to byte
> ```

At the point of `-x`, the compiler doesn't know that `x != 
x.min`, so VRP correctly prevents this. Do you think the compiler 
should allow it? How would it decide that? (If `x` is const, it 
can be assigned to a byte).


More information about the Digitalmars-d-learn mailing list