Skip to content

Error message inconsistency caused by in-function mapping declaration #15564

Open
@haoyang9804

Description

@haoyang9804

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions