If I define the following struct like this:

struct MyStruct {
  uint256 type;

The Solidity compiler throws an error:

Expected identifier but got 'type'

I checked to have no mistake in my code and, when changing "type" with anything else, the error goes away.

Is "type" reserved in Solidity?

1 Answer 1


Yes, type is a reserved keyword in Solidity, according to the source code.

However, according to the docs, type is not a reserved keyword.

With that said, the reason it is reserved is for deriving type information on-chain. You can read more about it in the docs:

The expression type(X) can be used to retrieve information about the type X. Currently, there is limited support for this feature (X can be either a contract or an integer type) but it might be expanded in the future.

Edit: I would expect the error you received to read: ParserError: Expected identifier but got reserved keyword 'type'. This seems like a bug that should be resolved so that future developers do not have this issue as well.

Your Answer

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

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