Skip to content

Fix Statement.renameLhs to compare identifier names#467

Closed
tautschnig wants to merge 3 commits intomainfrom
tautschnig/fix-renameLhs
Closed

Fix Statement.renameLhs to compare identifier names#467
tautschnig wants to merge 3 commits intomainfrom
tautschnig/fix-renameLhs

Conversation

@tautschnig
Copy link
Contributor

Description of changes:

renameLhs was comparing lhs.name against the full Identifier 'fr' instead of 'fr.name', causing renames to never match when the metadata differed.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

renameLhs was comparing lhs.name against the full Identifier 'fr'
instead of 'fr.name', causing renames to never match when the
metadata differed.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Core.Statement.renameLhs so that LHS renaming matches identifiers by their name string rather than accidentally including identifier metadata, which previously prevented renames from matching when metadata differed.

Changes:

  • Updated Statement.renameLhs to compare lhs.name against fr.name in most statement constructors (init, set, call, havoc).
  • Updated function-declaration renaming logic in the .funcDecl branch (but see review comment about a remaining mismatch there).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

In Statement.renameLhs, the funcDecl branch compared decl.name (a
CoreIdent) with fr.name (a String). Due to Coe String CoreIdent,
fr.name was coerced to CoreIdent.unres fr.name, so the comparison
failed whenever decl.name.metadata ≠ Visibility.unres.

Fix by comparing decl.name.name (String) with fr.name (String),
consistent with all other branches (init, set, call, havoc).
Verify that Statement.renameLhs correctly renames a funcDecl when the
function name has different metadata (e.g., glob) than the fr identifier
(e.g., locl), and that it correctly skips renaming when names differ.
@atomb
Copy link
Contributor

atomb commented Feb 24, 2026

I'm a bit confused about this PR. The visibility parameter in identifiers exists specifically to make sure we can know that auto-generated names are distinct from other names because they have different visibility. Because of this, visibility is fundamentally part of the name, not metadata. Can you elaborate on what problem the current approach was causing?

@tautschnig
Copy link
Contributor Author

I'm a bit confused about this PR. The visibility parameter in identifiers exists specifically to make sure we can know that auto-generated names are distinct from other names because they have different visibility. Because of this, visibility is fundamentally part of the name, not metadata. Can you elaborate on what problem the current approach was causing?

Let me reconsider - it seems #289 is now also passing all tests when reverting this change. I'll see whether it comes up again when Laurel evolves in main.

@tautschnig tautschnig closed this Feb 24, 2026
auto-merge was automatically disabled February 24, 2026 22:58

Pull request was closed

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.

4 participants