The 31 Reserved Keywords in Solidity

Words with Special Meaning in Solidity

ยท

1 min read

The 31 Reserved Keywords 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

  1. after
  2. alias
  3. apply
  4. auto
  5. byte
  6. case
  7. copyof
  8. default
  9. defined
  10. final
  11. implements
  12. in
  13. inline
  14. let
  15. macro
  16. match
  17. mutable
  18. null
  19. of
  20. partial
  21. promise
  22. reference
  23. relocatable
  24. sealed
  25. sizeof
  26. static
  27. supports
  28. switch
  29. typedef
  30. typeof
  31. 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.

ย