The following is the sequence of steps taken by the Compiler to resolve references:
- Determine the initial block in which the search for the declaration begins.
- Find the referenced declaration and the block to which it belongs. Find the activation associated with that block.
- Evaluate the locator qualifier (if any) to obtain a pointer value.
- Evaluate the basis reference (if the reference is to a defined variable) and pointer.
- Determine all the extents (if any) of the referenced variables.
- Interpret the subscripts (if any).
- Invoke the procedure (if any).
Remember the following points when preparing for reference resolution:
- A fully or partially qualified structure reference is applicable to declarations of structures that include the same hierarchy of names as is used in the structure reference. A simple or subscripted reference to a name is applicable to any declaration of the name.
- A reference is resolved by finding the innermost block that contains any applicable declaration. If no containing block has an applicable declaration, the reference is invalid. If the block has only one applicable declaration, the reference is resolved to that declaration. If the block has more than one applicable declaration, the reference must be fully qualified to cite only one declaration in that block; otherwise, the reference is ambiguous and invalid.
- Once a block containing an applicable declaration is found, no containing blocks are searched in an attempt to resolve a reference.
- The presence of subscripts, arguments, or a locator qualifier has no effect on the resolution of a reference and cannot make an ambiguous reference unique.
- A simple or subscripted reference to a name X is considered to be a fully qualified reference to a nonmember declaration of X. This means that if a member and a nonmember are declared to have the name X in the same block, a reference to X is resolved to the nonmember. The member must be referenced using a structure qualified reference.