Skip to content

Commit 1472d4b

Browse files
authored
Merge pull request github#12062 from github/ginsbach/DocumentShadowing
shadowing in the handbook
2 parents 77283be + 4282e1a commit 1472d4b

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

docs/codeql/ql-language-reference/name-resolution.rst

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,22 @@ Local namespaces
216216
In addition to the global module, type, and predicate namespaces, each module defines a number of local
217217
module, type, and predicate namespaces.
218218

219-
For a module ``M``, it's useful to distinguish between its **declared**, **exported**, and **imported** namespaces.
220-
(These are described generically, but remember that there is always one for each of modules, types, and predicates.)
219+
For a module ``M``, it is useful to distinguish between its **privately declared**, **publically declared**, **exported**, and **visible** namespaces.
220+
(These are described generically, but remember that there is always one for each of modules, module signatures, types, type signatures, predicates, and predicate signatures.)
221+
222+
- The **privately declared** namespaces of ``M`` contain all entities and aliases that are declared—that is, defined—in ``M`` and that are annotated as ``private``.
223+
- The **publically declared** namespaces of ``M`` contain all entities and aliases that are declared—that is, defined—in ``M`` and that are not annotated as ``private``.
224+
- The **exported** namespaces of ``M`` contain
225+
1. all entries from the **publically declared** namespaces of ``M``, and
226+
2. for each module ``N`` that is imported into ``M`` with an import statement that is not annotated as ``private``: all entries from the **exported** namespaces of ``N`` that do not have the same name as any of the entries in the **publically declared** namespaces of ``M``.
227+
- The **visible** namespaces of ``M`` contain
228+
1. all entries from the **exported** namespaces of ``M``, and
229+
2. all entries from the **global** namespaces, and
230+
3. all entries from the **privately declared** namespace of ``M``, and
231+
4. for each module ``N`` that is imported into ``M`` with an import statement that is annotated as ``private``: all entries from the **exported** namespaces of ``N`` that do not have the same name as any of the entries in the **publically declared** namespaces of ``M``.
232+
5. if ``M`` is nested within a module ``N``: all entries from the **visible** namespaces of ``N`` that do not have the same name as any of the entries in the **publically declared** namespaces of ``M``, and
233+
6. all parameters of ``M``.
221234

222-
- The **declared** namespaces contain any names that are declared—that is, defined—in ``M``.
223-
- The **imported** namespaces contain any names exported by the modules that are imported into ``M`` using an
224-
:ref:`import statement <import-statements>`.
225-
- The **exported** namespaces contain any names declared in ``M``, or exported from a module imported into ``M``,
226-
except names annotated with ``private``. This includes everything in the imported namespaces that was not introduced
227-
by a private import.
228235

229236
This is easiest to understand in an example:
230237

@@ -248,12 +255,13 @@ This is easiest to understand in an example:
248255
}
249256
}
250257
251-
The module ``OneTwoThreeLib`` **imports** anything that is exported by the module ``MyFavoriteNumbers``.
258+
The module ``OneTwoThreeLib`` **publically declares** the class ``OneTwoThree`` and **privately declares** the module ``P``.
252259

253-
It **declares** the class ``OneTwoThree`` and the module ``P``.
260+
It **exports** the class ``OneTwoThree`` and anything that is exported by ``MyFavoriteNumbers``
261+
(assuming ``MyFavoriteNumbers`` does not export a type ``OneTwoThree``, which would not be **exported** by ``OneTwoThreeLib``).
254262

255-
It **exports** the class ``OneTwoThree`` and anything that is exported by ``MyFavoriteNumbers``.
256-
It does not export ``P``, since it is annotated with ``private``.
263+
Within it, the class ``OneTwoThree`` and the module ``P`` are **visible**, as well as anything exported by `MyFavoriteNumbers``
264+
(assuming ``MyFavoriteNumbers`` does not export a type ``OneTwoThree``, which would not be **visible** within ``OneTwoThreeLib``).
257265

258266
Example
259267
=======

0 commit comments

Comments
 (0)