Error message inconsistency caused by in-function mapping declaration
- Dominant language
- C++
- Stars
- 25.7k
- Forks
- 6.2k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 21
Description
## Description
```solidity
function f(mapping(uint128 => S) storage s) internal pure returns (mapping(uint128 => S) storage s2) {
s2 = s; // pass the compilation
s = s2; // TypeError: Types in storage containing (nested) mappings cannot be assigned to.
}
```
`s` and `s2` are both mapping-type declarations in function `f`. But the assignments to them cause different results.
Perhaps this is an intentional behavior, but the error message is misleading. It implies the assignment to `s2` should also be forbidden.
## Environment
- Compiler version: 0.8.28
Contributor guide
Research direction
Start by compiling the minimal Solidity function f with compiler version 0.8.28 and compare the diagnostics for the assignments to s2 and s. Done means the compiler's error message accurately reflects which mapping assignment is invalid, without implying that the valid assignment should also be rejected.
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