Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Identifiers

<identifier> ::= (<alpha_char> | "_") (<alpha_char> | <dec_digit> | "_")* ;

Dependencies:

  • <alpha_char>
  • <dec_digit>

The <identifier> is a C-style identifier, beginning with an alphabetic character or underscore, followed by zero or more alphanumeric or underscore characters.

Reserved names

Identifiers share their lexical space with keywords, primitive type names, and boolean literals. The lexer resolves ambiguity in the following priority order:

  1. EVM primitive typeu8u256, i8i256, b1b32, addr, bool, bit
  2. Keyword — e.g. let, fn, contract, mod, use, mut, pub, Self, …
  3. Boolean literaltrue, false
  4. Identifier — everything else

Any string that matches a higher-priority rule will never produce an Ident token. In particular, Self (capital S) is a reserved keyword and cannot be used as a plain identifier.

Special identifiers

The parser accepts self and super as identifiers in certain contexts (e.g. module paths, method receivers). These are keywords but are returned as identifier nodes with the names "self" and "super" respectively.