Skip to content

Special Variable Substitution#201

Open
rcosta358 wants to merge 4 commits intomainfrom
special-variable-substitution
Open

Special Variable Substitution#201
rcosta358 wants to merge 4 commits intomainfrom
special-variable-substitution

Conversation

@rcosta358
Copy link
Copy Markdown
Collaborator

@rcosta358 rcosta358 commented Apr 1, 2026

This PR changes the substitution of special variables so #ret_n is never replaced by another variable and #fresh_n is never used as the replacement for some other variable.

Example

Before

Refinement Error: x == x is not a subtype of #ret⁰ > 0

After

Refinement Error: #ret⁰ == x is not a subtype of #ret⁰ > 0

@rcosta358 rcosta358 self-assigned this Apr 1, 2026
@rcosta358 rcosta358 added the simplification Related to the simplification of expressions label Apr 1, 2026
@rcosta358 rcosta358 requested a review from CatarinaGamboa April 1, 2026 13:56
Copy link
Copy Markdown
Collaborator

@CatarinaGamboa CatarinaGamboa left a comment

Choose a reason for hiding this comment

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

lgtm, check the minor comments i left

} else if (left instanceof Var leftVar && right instanceof Var rightVar) {
// to substitute internal variable with user-facing variable
if (leftVar.isInternal() && !rightVar.isInternal()) {
if (isInternal(leftVar) && !isInternal(rightVar) && !isReturnVar(leftVar)) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could we have like a isKeywordVar or isSpecialVar to cover both Fresh and Ret?

}

private static boolean isFreshVar(Var var) {
return var.getName().startsWith("#fresh_");
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

could these be dependent on the final strings where we define the format for fresh and ret instead of hard coded?

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

Labels

simplification Related to the simplification of expressions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants