2

I'm trying to define a Struct type, and use it as a _keytype for a mapping.

contract TestContract
{
    struct Structure {
        bytes32 structure_name;
    }

    mapping (Structure => address) public test_mapping;
}

Using Solidity real time compiler I get the following error message:

Error: Expected elementary type name for mapping key type

However, according to Solidity's documentation, every data type except for 'mapping' can be used for _keytype:

Mapping types are declared as mapping _KeyType => _ValueType, where _KeyType can be almost any type except for a mapping and _ValueType can actually be any type, including mappings.

Did I understand the documentation wrongly?

1 Answer 1

2

Currently, a mapping with a struct as the key isn't supported.

It's a known issue:

https://github.com/ethereum/solidity/issues/599

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.