[Proposal]: A checked arithmetic expression on ushort/ubyte/byte can be lifted or inferred to return ushort/ubyte/byte in a checked context. #7710
Replies: 4 comments 2 replies
-
This is similar and particularly frustrating:
|
Beta Was this translation helpful? Give feedback.
-
IIRC, this has to do with how the CIL encodes arithmetic operations (everything is upcast to an int or larger), not overflow support. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
If, in a checked context, you add a |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Checked expressions can use type inference to avoid compile-time errors.
Motivation
Subtracting from unsigned or small integer types currently requires a cast. Checked expressions already provide guarantees that the type system needs.
Currently this fails with a
CS0266
error. Allowing such expressions would thus be enabling a previously illegal statement, which is non-breaking from a language-only perspective.Design Meetings
None yet
Beta Was this translation helpful? Give feedback.
All reactions