You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/codeql/ql-language-reference/name-resolution.rst
+20-12Lines changed: 20 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -216,15 +216,22 @@ Local namespaces
216
216
In addition to the global module, type, and predicate namespaces, each module defines a number of local
217
217
module, type, and predicate namespaces.
218
218
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``.
221
234
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.
228
235
229
236
This is easiest to understand in an example:
230
237
@@ -248,12 +255,13 @@ This is easiest to understand in an example:
248
255
}
249
256
}
250
257
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``.
252
259
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``).
254
262
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``).
0 commit comments