Mirror of https://github.com/cue-lang/cue cuelang.org
cue go

cue/parser: allow a newline before the closing bracket of an index expression master

Per the existing comma insertion rules, a newline after an expression token inserts a comma. Index expressions did not allow a trailing comma, so splitting an index expression across multiple lines failed to parse: bar[ "baz" ] would report "expected ']', found newline". Amend the Index grammar to permit an optional trailing comma, matching both Go's grammar and the trailing-comma allowance already present in list and argument literals. This lets users split long index expressions across lines for readability without surprising errors. Fixes #2738. Signed-off-by: Daniel Martí <mvdan@mvdan.cc> Change-Id: Ibdf11f78d16deac90d8d27ab7b66b9138980ce0d Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1238111 TryBot-Result: CUEcueckoo <cueckoo@cuelang.org> Unity-Result: CUE porcuepine <cue.porcuepine@gmail.com> Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>


+44 -1
4 changed files