-
Notifications
You must be signed in to change notification settings - Fork 153
Fix for #204 #220
Fix for #204 #220
Conversation
|
❓ What does |
It still produces |
And the |
Yes. It is the same exact sequence: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💭 Consider rewording this paragraph. I don't feel that the references to "Roslyn" and "old-style equality comparison" help the reader understand why this code is needed. In fact, even if Roslyn didn't use this style of null check, it would still make since to include this. The following comes to mind.
Since there is no
cneinstruction, ECMA-335 §III.1.5 makes a note thatcgt.unmay be used instead for the specific case where the right-hand-side is null. For all integer inputs to thecgt.uninstruction, if the right side is null or zero, we treat the instruction as a "not equal" instruction for improved results from the static checker.
I checked the specification and it calls out |
This is a stronger statement than what's implemented. The code only deals with nulls on the right hand side, but not with integer zero. So, how about this:
|
|
👍 |
…n right hand side.
|
Oh, that explains some of the more subtle behaviours I saw when trying to compile the bug report. Nice work! |
|
Awesome job, guys! Merged. |
This fixes #204.
The culprit turned out to be the IL generated by Roslyn for comparing references to null. In the old compiler,
o => o != nullresults inwhich literally translates to
(o == null) == 0.In Roslyn, the same code results in
which literally translates to
o > null. While this is a clever trick and produces shorter IL, it doesn't match implicit non-null assumptions generated by the static checker and thus results in unproven assertions.The fix is to recognize the cases when
cgt.unis used to compare to null and make them look likeo != nullto the static checker.