Skip to content

Commit 5488872

Browse files
Merge pull request github#6505 from edoardopirovano/trailing-comma
QL Language Spec: Trailing comma in set literal
2 parents 413ac4e + 1802070 commit 5488872

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
@@ -1325,14 +1325,16 @@ Set literals denote a choice from a collection of values.
13251325

13261326
::
13271327

1328-
setliteral ::= "[" expr ("," expr)* "]"
1328+
setliteral ::= "[" expr ("," expr)* ","? "]"
13291329

13301330
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.
13311331

13321332
The values of a set literal expression are all the values of all the contained element expressions.
13331333

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

1336+
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.
1337+
13361338
Disambiguation of expressions
13371339
-----------------------------
13381340

@@ -2170,7 +2172,7 @@ The complete grammar for QL is as follows:
21702172
21712173
range ::= "[" expr ".." expr "]"
21722174
2173-
setliteral ::= "[" expr ("," expr)* "]"
2175+
setliteral ::= "[" expr ("," expr)* ","? "]"
21742176

21752177
simpleId ::= lowerId | upperId
21762178

0 commit comments

Comments
 (0)