Symbol References
A symbol reference names a binding or a global declaration by its name.
Name Resolution
The name of a symbol reference resolves as follows:
- the bindings visible in the innermost enclosing scope expression are searched first, then those of each enclosing scope expression in turn, and then the parameters of the enclosing function, if any;
- the lexically enclosing namespaces are searched in turn, innermost first;
- if still no declaration is found, the global scope is searched;
- if no declaration is found, a compile-time error is produced.
Qualified Names
A reference may continue with further segments, each a static access operation; the resolution of such chains is specified on that page.
The final segment's symbol must be usable in the position of the reference: a value in expression positions, a value of the type type in type positions or as the operand of a construction operation when it denotes a structure type, or a variant in construction operations and match patterns.
Structure fields are not resolved by reference lookup; a field is accessed dynamically, on a structure value; see dynamic access.
Syntax
symbol_reference = identifier ;