Solidity Compiler Error 9467: Inline Assembly Variables With 'slot' Suffix Causing False Identifier Not Found Errors
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 2d 19h
- Merged PRs (30d)
- 29
Description
## Description
The Solidity compiler is incorrectly interpreting variable names in inline assembly that end with "_slot" (e.g., "from_slot") as attempts to access storage variables rather than as locally declared assembly variables. This causes compilation `error 9467: "Identifier not found. Use '.slot' and '.offset' to access storage or transient storage variables."`
When using variable names like "from_slot" or "to_slot" in inline assembly, the compiler mistakenly interprets these as attempts to access storage slot properties. However, when the same variables are renamed to "slot_from" or "slot_to" (moving the word "slot" to the beginning), the code compiles successfully. This suggests the compiler is incorrectly parsing variable names that end with "_slot".
## Environment
- Compiler version:0.8.28
## Steps to Reproduce
```solidity
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
contract test{
function transfer(address _to, uint256 _value)public{
assembly{
let ptr:=mload(0x40)
mstore(ptr,caller())
mstore(add(ptr,0x20),1)
let from_slot:=keccak256(ptr,0x40)
let from_Balance:=sload(from_slot)
}
}
```
-->
Contributor guide
Research direction
Start by compiling the Solidity reproduction with compiler version 0.8.28, then compare the failing `from_slot` and `to_slot` names with the working `slot_from` and `slot_to` variants. Trace the compiler's inline-assembly identifier handling and add coverage showing that locally declared names ending in `_slot` are accepted without the storage-variable error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, solidity
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100