Increment on nullable always compiles to a conditional #81637
-
|
Increment on int? n = 0;
++n;This gets compiled to: So, it is still calling Am I missing something? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
We have no such concept. We track of something has been assigned. We also have weak linting heuristics around if something could be null or not. However, we have a strong stance that that doesn't change codegen or semantics at all. It just affects if certain warnings are emitted. |
Beta Was this translation helpful? Give feedback.
-
Seems an issue on their end. |
Beta Was this translation helpful? Give feedback.
-
|
Note: i'm not opposed to the compiler having some local-only smarts where it might know accurately that a value is not null, and thus certain things could be elided. It might be some sort of optimization pass. But it seems very optional, and something that would be fine to never come. Personally, i'd just like it to ease the burden on the jit, and generate more ideal IL/assembler. |
Beta Was this translation helpful? Give feedback.
Ah, I thought flow analysis wasn't just for warnings but also for optimized codegen, at least in simple cases. Thank you for clarifying.