Skip to content

Commit 1802070

Browse files
QL Language Spec: Trailing comma in set literal
1 parent d325d2a commit 1802070

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

docs/codeql/ql-language-reference/ql-language-specification.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,14 +1323,16 @@ Set literals denote a choice from a collection of values.
13231323

13241324
::
13251325

1326-
setliteral ::= "[" expr ("," expr)* "]"
1326+
setliteral ::= "[" expr ("," expr)* ","? "]"
13271327

13281328
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.
13291329

13301330
The values of a set literal expression are all the values of all the contained element expressions.
13311331

13321332
Set literals are supported from release 2.1.0 of the CodeQL CLI, and release 1.24 of LGTM Enterprise.
13331333

1334+
Since release 2.6.3 of the CodeQL CLI, and release 1.28 of LGTM Enterprise, a trailing comma is allowed in a set literal.
1335+
13341336
Disambiguation of expressions
13351337
-----------------------------
13361338

@@ -2168,7 +2170,7 @@ The complete grammar for QL is as follows:
21682170
21692171
range ::= "[" expr ".." expr "]"
21702172
2171-
setliteral ::= "[" expr ("," expr)* "]"
2173+
setliteral ::= "[" expr ("," expr)* ","? "]"
21722174

21732175
simpleId ::= lowerId | upperId
21742176

0 commit comments

Comments
 (0)