Skip to content

Fix Enum.Equals folding for nullable boxed arguments - #133826

Draft
EgorBo with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-nullreferenceexception-enum-equals
Draft

Fix Enum.Equals folding for nullable boxed arguments#133826
EgorBo with Copilot wants to merge 3 commits into
mainfrom
copilot/fix-nullreferenceexception-enum-equals

Conversation

Copilot AI commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Boxing a nullable enum can yield null while retaining an exact enum type. Enum.Equals folding currently dereferences that argument, throwing instead of returning false.

  • JIT: Require a known non-null argument before comparing boxed payloads; otherwise retain the call. Preserve null-receiver exception behavior.
  • Coverage: Add nullable-boxing cases for null, equal, and unequal arguments.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
16 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@github-actions github-actions Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 13, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Enum.Equals folding for null argument to return false Fix Enum.Equals folding for nullable boxed arguments Sep 13, 2026
Copilot AI requested a review from EgorBo September 13, 2026 16:55
@EgorBo

EgorBo commented Sep 13, 2026

Copy link
Copy Markdown
Member

@copilot fix ci failures

Co-authored-by: EgorBo <523221+EgorBo@users.noreply.github.com>

Copilot AI commented Sep 13, 2026

Copy link
Copy Markdown
Contributor Author

@copilot fix ci failures

Fixed in e2f6aba. Enum-valued [InlineData] broke assembly aliases in the merged runner; all four cases now run from TestEntryPoint. Reproduced the CI compile failure, then rebuilt JIT_others successfully and passed enum coverage in four JIT modes. The other failures in that CI run are known issues #133798 and #133645.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JIT (bug): Enum.Equals folding throws NullReferenceException instead of returning false for a null argument

2 participants