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/ql-language-specification.rst
+22-11Lines changed: 22 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -862,20 +862,20 @@ A valid class may not inherit from a final class, from itself, or from more than
862
862
Class environments
863
863
~~~~~~~~~~~~~~~~~~
864
864
865
-
For each of modules, types, predicates, and fields a class *inherits*, *declares*, and *exports* an environment. These are defined as follows (with X denoting the type of entity we are currently considering):
865
+
For each of member predicates and fields a class *inherits* and *declares*, and *exports* an environment. These are defined as follows (with X denoting the type of entity we are currently considering):
866
866
867
-
- The *inherited X environment* of a class is the union of the exported X environments of its base types.
867
+
- The *inherited X environment* of a class is the union of the exported X environments of types it inherits from, excluding any elements that are ``overridden`` by another element.
868
868
869
869
- The *declared X environment* of a class is the multimap of X declarations in the class itself.
870
870
871
871
- The *exported X environment* of a class is the overriding union of its declared X environment (excluding ``private`` declaration entries) with its inherited X environment.
872
872
873
-
- The *external X environment* of a class is the visible X environment of the enclosing module.
874
-
875
-
- The *visible X environment* is the overriding union of the declared X environment and the inherited X environment; overriding unioned with the external X environment.
873
+
- The *visible X environment* is the overriding union of the declared X environment and the inherited X environment.
876
874
877
875
The program is invalid if any of these environments is not definite.
878
876
877
+
For each of member predicates and fields a domain type *exports* an environment. This is the union of the exported ``X`` environments of types the class inherits from, excluding any elements that are ``overridden`` by another element.
878
+
879
879
Members
880
880
~~~~~~~
881
881
@@ -899,7 +899,7 @@ Member predicates
899
899
900
900
A predicate that is a member of a class is called a *member predicate*. The name of the predicate is the identifier just before the open parenthesis.
901
901
902
-
A member predicate adds a mapping from the predicate name and arity to the predicate declaration in the class's declared predicate environment.
902
+
A member predicate adds a mapping from the predicate name and arity to the predicate declaration in the class's declared member predicate environment.
903
903
904
904
A valid member predicate can be annotated with ``abstract``, ``cached``, ``final``, ``private``, ``deprecated``, and ``override``.
905
905
@@ -922,7 +922,7 @@ A valid class must include a non-private predicate named ``toString`` with no ar
922
922
A valid class may not inherit from two different classes that include a predicate with the same name and number of arguments, unless either one of the predicates overrides the other, or the class defines a predicate that overrides both of them.
923
923
924
924
The typing environment for a member predicate or character is the same as if it were a non-member predicate, except that it additionally maps ``this`` to a type and also maps any fields on a class to a type. If the member is a character, then the typing environment maps ``this`` to the class domain type of the class. Otherwise, it maps ``this`` to the class type of the class itself.
925
-
It any field to the type of the field.
925
+
The typing environment also maps any field to the type of the field.
926
926
927
927
Fields
928
928
^^^^^^
@@ -1163,13 +1163,24 @@ The expressions in parentheses are the *arguments* of the call. The expression b
1163
1163
1164
1164
The type environment for the arguments is the same as for the call.
1165
1165
1166
-
A valid call with results must *resolve* to exactly one predicate. The ways a call can resolve are as follows:
1166
+
A valid call with results *resolves* to a set of predicates. The ways a call can resolve are as follows:
1167
+
1168
+
- If the call has no receiver and the predicate name is a simple identifier, then the predicate is resolved by looking up its name and arity in the visible member-predicate environment of the enclosing class.
1169
+
1170
+
- If the call has no receiver and the predicate name is a simple identifier, then the predicate is resolved by looking up its name and arity in the visible predicate environment of the enclosing module.
1171
+
1172
+
- If the call has no receiver and the predicate name is a selection identifier, then the qualifier is resolved as a module (see "`Module resolution <#module-resolution>`__"). The identifier is then resolved in the exported predicate environment of the qualifier module.
1173
+
1174
+
- If the call has a super expression as the receiver, then it resolves to a member predicate in a class the enclosing class inherits from. If the super expression is unqualified, then the super-class is the single class that the current class inherits from. If there is not exactly one such class, then the program is invalid. Otherwise the super-class is the class named by the qualifier of the super expression. The predicate is resolved by looking up its name and arity in the exported predicate environment of the super-class.
1175
+
1176
+
- If the type of the receiver is the same as the the enclosing class the predicate is resolved by looking up its name and arity in the ``visible`` predicate environment of the class.
1167
1177
1168
-
- If the call has no receiver, then it can resolve to a non-member predicate. If the predicate name is a simple identifier, then the predicate is resolved by looking up its name and arity in the visible predicate environment of the enclosing class or module.
1178
+
- If the type of the receiver is not the same as the the enclosing class the predicate is resolved by looking up its name and arity in the ``exported`` predicate environment of the class or domain type.
1169
1179
1170
-
If the predicate name is a selection identifier, then the qualifier is resolved as a module (see "`Module resolution <#module-resolution>`__"). The identifier is then resolved in the exported predicate environment of the qualifier module.
1180
+
If all the predicates that the call resolves to are declared on a primitive type we then restrict to the set of predicates where each argument of the call is a subtype of the corresponding predicate argument type.
1181
+
Then we find all predicates ``p`` from this new set such that there is not another predicate ``p'``where each argument of ``p'`` is a subtype of the corresponding argument in ``p``. We then say the call resolves to this set instead.
1171
1182
1172
-
- If the call has a super expression as the receiver, then it resolves to a member predicate in a class the enclosing class inherits from. If the super expression is unqualified, then the super-class is the single class that the current class inherits from. If there is not exactly one such class, then the program is invalid. Otherwise the super-class is the class named by the qualifier of the super expression. The predicate is resolved by looking up its name and arity in the exported predicate environment of the super-class. If there is more than one such predicate, then the predicate call is not valid.
1183
+
A valid call must only resolve to a single predicate.
1173
1184
1174
1185
For each argument other than a don't-care expression, the type of the argument must be compatible with the type of the corresponding argument type of the predicate, otherwise the call is invalid.
0 commit comments