Skip to content

Commit 875a70c

Browse files
authored
Merge pull request github#3129 from ginsbach/master
Set Literal in QL
2 parents fad902f + 71c588a commit 875a70c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

docs/language/ql-spec/language.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,6 +1168,21 @@ If both expressions are subtypes of ``int`` then the type of the range is ``int`
11681168

11691169
The values of a range expression are those values which are ordered inclusively between a value of the first expression and a value of the second expression.
11701170

1171+
Set Literals
1172+
~~~~~~~~~~~~
1173+
1174+
Set literals denote a choice from a collection of values.
1175+
1176+
::
1177+
1178+
setliteral ::= "[" expr ("," expr)* "]"
1179+
1180+
Set literals can be of any type, but the types within a set literal have to be consistent according to the following criterion: At least one of the set elements has to be of a type that is a supertype of all the set element types. This supertype is the type of the set literal. For example, ``float`` is a supertype of ``float`` and ``int``, therefore ``x = [4, 5.6]`` is valid. On the other hand, ``y = [5, "test"]`` does not adhere to the criterion.
1181+
1182+
The values of a set literal expression are all the values of all the contained element expressions.
1183+
1184+
Set literals are supported from release 2.1.0 of the CodeQL CLI, and release 1.24 of LGTM Enterprise.
1185+
11711186
Disambiguation of expressions
11721187
-----------------------------
11731188

@@ -1934,6 +1949,7 @@ The complete grammar for QL is as follows:
19341949
| aggregation
19351950
| any
19361951
| range
1952+
| setliteral
19371953

19381954
eparen ::= "(" expr ")"
19391955

@@ -1973,6 +1989,8 @@ The complete grammar for QL is as follows:
19731989
| primary "." predicateName (closure)? "(" (exprs)? ")"
19741990
19751991
range ::= "[" expr ".." expr "]"
1992+
1993+
setliteral ::= "[" expr ("," expr)* "]"
19761994

19771995
simpleId ::= lowerId | upperId
19781996

0 commit comments

Comments
 (0)