feat(parser): accept list literals in field-function arguments
What does this MR do and why?
Third of three MRs for list-valued field-function parameters. Stacked on !520 (merged) (typed values) and !521 (merged) (list definitions). This is the language change.
Syntax: name(key=[v1, v2, ...]) and name([v1, v2]), items being the scalar forms field functions already accept (quoted strings, identifiers, numbers); [] is the empty list. Brackets rather than the parenthesised list filters use, because inside a call (...) would read as a nested function. [ has no other use in the grammar. Numbers may be negative (foo(-1), tiers=[-10, 0, 10]), matching what the integer validators accept.
- Malformed lists (unterminated, trailing comma, empty item, nested list, missing separator) fail to parse;
FieldFunctionkeys with list items re-parse to the same value. - Several positional values for a single list parameter (
userTier(4, 25, 100)) get an error pointing at the bracketed spelling instead of the generic arity message. - The
Listvalue kind inschema.jsondocuments both spellings: parenthesised in a filter, bracketed in a field-function parameter. That is the only change to the document. to_sentence_case, which labels every field-function argument and list item, handles a multi-byte first character and inputs without word characters instead of panicking.
The first users are userTier(thresholds=[...]) in !516 (merged), stacked on this MR, and totalCount(status=[...]) for #215 (closed); end-to-end examples live there.
Follow-ups outside this repo
- Grammar docs for field functions live in gitlab-org/gitlab (
doc/user/glql/) and need the list syntax once a release ships it. - The monolith's
labelWithParameter(app/assets/javascripts/glql/utils/chart_data.js) stringifies an array parameter as4,25,100in the label suffix (aliasing hides it); flattening the parameter values before stringifying is a cosmetic follow-up alongside the bump.
How to review
src/parser/fields.rs (list_arg_value, scalar_arg_value, the tests), src/utils/common.rs.
Closes #213 (closed)