Fix Usage Detection for Repeated Equalities#226
Conversation
|
what do you mean by "a matching equality is only excluded as a definition when it appears in a definition under a conjunction"? |
|
Those two expressions are equivalent. It's not about the order of the conjunctions, it's about whether the equality appears as a top level conjunct or nested inside another expression. In both examples, the outer |
CatarinaGamboa
left a comment
There was a problem hiding this comment.
Can we add a couple more tests to ensure similar but more complex expressions are working?
Maybe like:
mode == 2 && other == 5 && ((mode == 2 && other == 5) ? explicit(param) : start(param)) -> explicit(param)
or
"mode == 2 && other == 3 && (mode == 2 ? (other == 3 ? a(p) : b(p)) : c(p))" -> a(p)
Description
This PR fixes the
VariableResolver.hasUsageso a matching equality is only excluded as a definition when it appears in a definition under a conjunction. This means that repeated equalities inside nested expressions now count as usages, allowing substitutions to propagate and simplify correctly.Example
Before
Both
x == 1count has definitions.After
The first one counts has a definition and the second one counts as an usage.
Related Issue
None.
Type of change
Checklist
ExpressionSimplifierTestsandVariableResolverTestsmvn testpasses locally