Skip to content

nr2.0: Update IdentifierPattern's subpattern name resolution #3828

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
merged 1 commit into from
Jun 17, 2025

Conversation

Polygonalr
Copy link
Contributor

Addresses this comment, thanks to @P-E-P for explaining the rationale for this change over meeting :)

gcc/rust/ChangeLog:

	* resolve/rust-late-name-resolver-2.0.cc (Late::visit(IdentifierPattern)):
	Remove redundant subpattern check.

Signed-off-by: Yap Zhi Heng <[email protected]>
@powerboat9
Copy link
Collaborator

@P-E-P it looks like IdentifierPattern::get_subpattern doesn't return an optional and has the line

rust_assert (has_subpattern ());

@P-E-P
Copy link
Member

P-E-P commented Jun 16, 2025

@P-E-P it looks like IdentifierPattern::get_subpattern doesn't return an optional and has the line

rust_assert (has_subpattern ());

Right now the focus is the semantic aspect within the class ("yes that value can be missing and that null pointer IS a bug"), not at the class boundaries. This means you can keep the assert on the getter, if you really want to go the extra mile you can even rename it to get_subpattern_unchecked (it has been done in the codebase before, grep for _unchecked within the rust directory). If we have some time later we'll introduce proper optional APIs for the getters (and grepping "unchecked" will help) but for now the true goal is communicating the intent of the class to easily tell appart buggy null pointers from none values.

@powerboat9
Copy link
Collaborator

Oh, wait, nvm -- I should have read the patch more closely. Looks good

Copy link
Member

@P-E-P P-E-P left a comment

Choose a reason for hiding this comment

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

LGTM

@P-E-P P-E-P added this pull request to the merge queue Jun 17, 2025
Merged via the queue into Rust-GCC:master with commit d31e537 Jun 17, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants