slither
slither copied to clipboard
fix: expand add_refers_to assertion to accept TopLevelVariable
Summary
The add_refers_to method in LocalIRVariable was failing with an AssertionError during SSA generation when the rvalue was a TopLevelVariable (file-level constant/immutable).
This fix expands the assertion to accept TopLevelVariable in addition to the existing SlithIRVariable and TemporaryVariable types.
Details
-
Root cause: When analyzing contracts that reference file-level constants/immutables in storage pointer contexts, the SSA generation passes a
TopLevelVariabletoadd_refers_to, which only acceptedSlithIRVariableandTemporaryVariable. -
Similar precedent: PR #1968 fixed a similar issue where
TopLevelVariablewasn't supported in other slithir operations (index.py,reference.py).