forked from Mirror/wren
Allow trailing comma in map literal
This commit is contained in:
committed by
Bob Nystrom
parent
6559edbc56
commit
e1d3596643
@ -1853,6 +1853,9 @@ static void map(Compiler* compiler, bool allowAssignment)
|
|||||||
{
|
{
|
||||||
ignoreNewlines(compiler);
|
ignoreNewlines(compiler);
|
||||||
|
|
||||||
|
// Map with trailing comma.
|
||||||
|
if (peek(compiler) == TOKEN_RIGHT_BRACE) break;
|
||||||
|
|
||||||
// Push a copy of the map since the subscript call will consume it.
|
// Push a copy of the map since the subscript call will consume it.
|
||||||
emit(compiler, CODE_DUP);
|
emit(compiler, CODE_DUP);
|
||||||
|
|
||||||
|
|||||||
7
test/language/map/trailing_comma.wren
Normal file
7
test/language/map/trailing_comma.wren
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
var map = {
|
||||||
|
"a": 1,
|
||||||
|
"b": 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
IO.print(map["a"]) // expect: 1
|
||||||
|
IO.print(map["b"]) // expect: 2
|
||||||
Reference in New Issue
Block a user