8.3 Resolution
In this section, we describe the order in which namespaces are
searched to resolve identifiers.
Given an unqualified identifier, references are resolved as follows:
- Lookup the identifier in the current namespace
(where the reference is made).
If a match is found, it is guaranteed to be unique,
otherwise, continue searching.
- Lookup the identifier in each imported and aliased namespace.
If a unique match is found, return it.
In the case of multiple matches (in different namespaces),
report ambiguity as an error.
If no matches are found, continue searching.
- If not already in the global namespace,
continue searching using steps 1 and 2 in the parent namespace.
Return the first unique match found or an error if zero
or more than one match is found.