feat: extract argument list parsing into finishArgumentList helper

Extract the duplicated argument list parsing logic from methodCall and
subscript into a shared finishArgumentList function. This unifies the
comma-separated expression parsing, arity tracking, and newline handling
into a single location. Also add a new test case verifying that newlines
after commas and before closing delimiters are correctly handled in both
method calls and subscript expressions.
This commit is contained in:
Bob Nystrom
2015-02-22 18:42:49 +00:00
parent 609082b3ba
commit c1fc6adcb4
2 changed files with 47 additions and 27 deletions
+20
View File
@@ -0,0 +1,20 @@
class Foo {
method(a, b) { "method " + a + " " + b }
[a, b] { "subscript " + a + " " + b }
}
var foo = new Foo
// Allow newlines after commas and before ")".
IO.print(foo.method("a",
"b"
)) // expect: method a b
// Allow newlines after commas and before "]".
IO.print(foo["a",
"b"
]) // expect: subscript a b