-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
...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 finished work on behalf of
jcouv
October 14, 2025 21:28
jcouv
jcouv
approved these changes
Oct 14, 2025
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.
LGTM (commit 2)
333fred
333fred
approved these changes
Oct 14, 2025
RikkiGibson
RikkiGibson
approved these changes
Oct 15, 2025
This was referenced Oct 17, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
Fixes #57179
This PR adds a validation check in
LocalRewritingValidator
to enforce thatBoundUnconvertedObjectCreationExpression
nodes do not survive past local rewriting.Background
BoundUnconvertedObjectCreationExpression
represents target-typednew()
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 aVisitUnconvertedObjectCreationExpression
method that throwsExceptionUtilities.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 theLocalRewritingValidator
class that:Fail(node)
to trigger a debug assertion if an unconverted object creation expression is encounteredVisitDefaultLiteral
,VisitUsingStatement
, etc.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
new()
expressions)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
Fixes #57179
💬 Share your feedback on Copilot coding agent for the chance to win a 200ドル gift card! Click here to start the survey.