slither icon indicating copy to clipboard operation
slither copied to clipboard

Detect unused local variables (including in Yul blocks)

Open mds1 opened this issue 2 years ago • 2 comments

What bug did Slither miss and which detector did you anticipate would catch it?

  1. Clone the optimism repo and cd packages/contracts-bedrock.
  2. Open L1Block.sol and in setL1BlockValuesEcotone, notice the unused let data := calldataload(4).
  3. Update the slither.config.json so no checks are excluded.
  4. Run slither . (side error: running slither ./src/L2/L1Block.sol gives a compilation error that I haven't looked into yet), which does not find the unused data variable.

Frequency

Not sure

Code example to reproduce the issue:

See above

Version:

0.10.0

Relevant log output:

No response

mds1 avatar Feb 20 '24 16:02 mds1

We have worked some on an unused-local detector but haven't released it due to FPs. Is there another detector you thought would catch this?

0xalpharush avatar Feb 20 '24 17:02 0xalpharush

Ah, I thought I'd seen unused variables in the past but perhaps unused-state-variable is what I was remembering. In which case, we can convert this into a feature request

mds1 avatar Feb 20 '24 18:02 mds1