slither icon indicating copy to clipboard operation
slither copied to clipboard

fix: expand add_refers_to assertion to accept TopLevelVariable

Open nisedo opened this issue 1 month ago • 0 comments

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 TopLevelVariable to add_refers_to, which only accepted SlithIRVariable and TemporaryVariable.

  • Similar precedent: PR #1968 fixed a similar issue where TopLevelVariable wasn't supported in other slithir operations (index.py, reference.py).

nisedo avatar Dec 02 '25 09:12 nisedo