The 31 Reserved Keywords in Solidity
Words with Special Meaning in Solidity
Reserved keywords are special words defined in programming languages that have Special meanings and should not be used as Identiifiers.
These keywords are reserved to write the programming logic and should not be used to name variables and functions.
However, If you do use them to name variables or functions your code would not run correctly.
Here are the 31 keywords available in Solidity.
The 31 Reserved Keywords
- after
- alias
- apply
- auto
- byte
- case
- copyof
- default
- defined
- final
- implements
- in
- inline
- let
- macro
- match
- mutable
- null
- of
- partial
- promise
- reference
- relocatable
- sealed
- sizeof
- static
- supports
- switch
- typedef
- typeof
- var
What if I use a reserved keyword as an Identiifier?
This would raise a parser error
and your code won't compile.
ParserError: Expected identifier but got reserved keyword
How to fix the ParserError?
Scan your code for instances where you used a keyword as a variable name. Or a function name.
Then replace every single instance with a non-reserved keyword.
Look through the list above and avoid every single one of them.
Hi, I am koha and I am sharing my web3 journey here and on youtube.
ย