forked from Mirror/wren
Allow trailing comma in list literal
This commit is contained in:
committed by
Bob Nystrom
parent
e1d3596643
commit
b20c9a1b38
@ -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);
|
||||
|
||||
|
||||
7
test/language/list/trailing_comma.wren
Normal file
7
test/language/list/trailing_comma.wren
Normal file
@ -0,0 +1,7 @@
|
||||
var list = [
|
||||
"a",
|
||||
"b",
|
||||
]
|
||||
|
||||
IO.print(list[0]) // expect: a
|
||||
IO.print(list[1]) // expect: b
|
||||
Reference in New Issue
Block a user