1
0
forked from Mirror/wren

Allow trailing comma in list literal

This commit is contained in:
Lukas Werling
2015-05-30 22:18:37 +02:00
committed by Bob Nystrom
parent e1d3596643
commit b20c9a1b38
2 changed files with 10 additions and 0 deletions

View File

@ -1816,6 +1816,9 @@ static void list(Compiler* compiler, bool allowAssignment)
{
ignoreNewlines(compiler);
// List with trailing comma.
if (peek(compiler) == TOKEN_RIGHT_BRACKET) break;
// Push a copy of the list since the add() call will consume it.
emit(compiler, CODE_DUP);

View File

@ -0,0 +1,7 @@
var list = [
"a",
"b",
]
IO.print(list[0]) // expect: a
IO.print(list[1]) // expect: b