Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InternalCompilerError: Invalid stack item name: slot with --via-ir #13260

Closed
Vectorized opened this issue Jul 10, 2022 · 1 comment
Closed

InternalCompilerError: Invalid stack item name: slot with --via-ir #13260

Vectorized opened this issue Jul 10, 2022 · 1 comment

Comments

@Vectorized
Copy link
Contributor

Description

Compiler gives an error InternalCompilerError: Invalid stack item name: slot when compiling with --via-ir,
when an assembly block calls .slot on a reference to a mapping.

Environment

  • Compiler version: 0.8.15

Steps to Reproduce

Found in ERC721A, when compiling with --via-ir

function _getApprovedAddress(uint256 tokenId)
    private
    view
    returns (uint256 approvedAddressSlot, address approvedAddress)
{
    mapping(uint256 => address) storage tokenApprovalsPtr = _tokenApprovals;
    // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId]`.
    assembly {
        // Compute the slot.
        mstore(0x00, tokenId)
        mstore(0x20, tokenApprovalsPtr.slot) // This line causes the compiler error.
        approvedAddressSlot := keccak256(0x00, 0x40)
        // Load the slot's value from storage.
        approvedAddress := sload(approvedAddressSlot)
    }
}

The code compiles normally without --via-ir.

See: chiru-labs/ERC721A#364

@Vectorized
Copy link
Contributor Author

Vectorized commented Jul 10, 2022

Issue already opened.

Please refer to #13259

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant