Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add LocalRewritingValidator check for BoundUnconvertedObjectCreationExpression #80724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
jcouv merged 2 commits into main from copilot/modify-local-rewriting-validator
Oct 15, 2025

Conversation

Copy link
Contributor

@Copilot Copilot AI commented Oct 14, 2025
edited by jcouv
Loading

Fixes #57179

This PR adds a validation check in LocalRewritingValidator to enforce that BoundUnconvertedObjectCreationExpression nodes do not survive past local rewriting.

Background

BoundUnconvertedObjectCreationExpression represents target-typed new() expressions before they are converted to their actual target type during binding. These nodes should be fully converted during the binding phase and should never reach the local rewriting phase.

The main LocalRewriter class already has a VisitUnconvertedObjectCreationExpression method that throws ExceptionUtilities.Unreachable(), indicating these nodes are unexpected during local rewriting. However, there was no corresponding DEBUG-time validation to catch cases where such nodes might inadvertently survive into the local rewriting phase.

Changes

Added a VisitUnconvertedObjectCreationExpression method to the LocalRewritingValidator class that:

  • Calls Fail(node) to trigger a debug assertion if an unconverted object creation expression is encountered
  • Follows the same pattern as existing validator methods like VisitDefaultLiteral, VisitUsingStatement, etc.
  • Only executes in DEBUG builds (the entire LocalRewritingValidator class is #if DEBUG)

This provides an additional safety net to catch potential bugs during development where unconverted object creation expressions might leak into the local rewriting phase.

Testing

  • All existing tests pass, including:
    • 163 ImplicitObjectCreationTests (target-typed new() expressions)
    • 94 TargetTyped tests
    • Full Compilers.slnf solution builds successfully

The change is minimal (6 lines) and follows established patterns in the codebase.

Originally requested by @jcouv in #57091 (comment)

Co-authored-by: jcouv 12466233+jcouv@users.noreply.github.com

Original prompt

This section details on the original issue you should resolve

<issue_title>Can we modify LocalRewritingValidator to enforce that BoundUnconvertedObjectCreation does not survive past local rewriting?</issue_title>
<issue_description>Can we modify LocalRewritingValidator to enforce that BoundUnconvertedObjectCreation does not survive past local rewriting?

Originally posted by @jcouv in #57091 (comment) </issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #57179


💬 Share your feedback on Copilot coding agent for the chance to win a 200ドル gift card! Click here to start the survey.

...xpression
Co-authored-by: jcouv <12466233+jcouv@users.noreply.github.com>
@Copilot Copilot AI changed the title (削除) [WIP] Modify LocalRewritingValidator to restrict BoundUnconvertedObjectCreation (削除ここまで) (追記) Add LocalRewritingValidator check for BoundUnconvertedObjectCreationExpression (追記ここまで) Oct 14, 2025
@Copilot Copilot AI requested a review from jcouv October 14, 2025 21:28
Copilot finished work on behalf of jcouv October 14, 2025 21:28
Copy link
Member

@jcouv jcouv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM (commit 2)

@jcouv jcouv marked this pull request as ready for review October 14, 2025 22:09
@jcouv jcouv requested a review from a team as a code owner October 14, 2025 22:09
@jcouv jcouv merged commit 93f2ebf into main Oct 15, 2025
24 checks passed
@jcouv jcouv deleted the copilot/modify-local-rewriting-validator branch October 15, 2025 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@333fred 333fred 333fred approved these changes

@RikkiGibson RikkiGibson RikkiGibson approved these changes

+1 more reviewer

@jcouv jcouv jcouv approved these changes

Reviewers whose approvals may not affect merge requirements

Labels

None yet

Projects

None yet

Milestone

Next

Development

Successfully merging this pull request may close these issues.

Can we modify LocalRewritingValidator to enforce that BoundUnconvertedObjectCreation does not survive past local rewriting?

AltStyle によって変換されたページ (->オリジナル) /