feat: allow trailing comma in list literal by early break on right bracket
Add support for trailing commas in list literals by checking for TOKEN_RIGHT_BRACKET after parsing the last element in the list() function. When a trailing comma is followed by the closing bracket, the loop breaks immediately instead of attempting to parse another element. Include a test case verifying that lists with trailing commas parse correctly and elements are accessible by index.
This commit is contained in:
@@ -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