Reserved Keywords in Solidity

There are 31 reserved keywords in the Solidity programming language as of version 0.8.14. These reserved words are part of the syntax and have a special meaning to the compiler, they can not be used as an identifier for variables. 

Unfortunately most IDEs like remix don't highlight the reserved keywords in another color, to prevent users from using them as identifiers for variables and functions. So it's the developers responsibility to respect the reserved keywords.

Reserved Keywords in Solidity

  • after
  • alias
  • apply
  • auto
  • byte
  • case
  • copyof
  • default
  • define
  • final
  • implements
  • in
  • inline
  • let
  • macro
  • match
  • mutable
  • null
  • of
  • partial
  • promise
  • reference
  • relocatable
  • sealed
  • sizeof
  • static
  • supports
  • switch
  • typedef
  • typeof
  • var

What happens if reserved keywords are used?

In case a reserved keyword is used, for example as a variable name, a ParserError is raised. ParserError: Expected identifier but got reserved keyword To fix the ParserError, use a non-reserved identifier. In general variable names have to start with a letter or underscore (_) and contain letters, digits and other characters.



Click to jump to section