chiru-labs / ERC721A

https://ERC721A.org
MIT License
2.51k stars 841 forks source link

⚠️ `Invalid stack item name: slot` #365

Closed Vectorized closed 2 years ago

Vectorized commented 2 years ago

Solution:

Turn off --via-ir.

This is caused by the following:

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)
    }
}

See: https://twitter.com/emo_eth/status/1546209685635600384

@axic