Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
RblSb committed Mar 10, 2023
1 parent ae0eeb1 commit 78d6f2a
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/syntax/grammar.mly
Original file line number Diff line number Diff line change
Expand Up @@ -1670,12 +1670,10 @@ and parse_call_params f p1 s =
mk_null_expr (punion_next p1 s)
in
match s with parser
| [< '(PClose,p2) >] ->
| [< '(PClose,p2) >]
| [< '(Comma,_); '(PClose,p2) >] ->
let e = check_signature_mark e p1 p2 in
f (List.rev (e :: acc)) p2
| [< '(Comma,p2); '(PClose,p3) >] ->
let e = check_signature_mark e p1 p3 in
f (List.rev (e :: acc)) p3
| [< '(Comma,p2) >] ->
let e = check_signature_mark e p1 p2 in
parse_next_param (e :: acc) p2
Expand Down
43 changes: 43 additions & 0 deletions tests/misc/projects/trailing-commas/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
class Main {
static function f(t:Type.ValueType, t2:Type.ValueType,) {}
public static function main():Void {
f(TNull,TNull,);
foobar(
1,
2,
);
function blah(
a:Int,
b:Int,
):Void {}
var a = (
a:Int,
b:Int,
) -> 0;
var a:(
a:Int,
b:Int,
)->Int = null;
a = (a, b,) -> a + b;
trace(a(2, 3,) + moduleFoobar(5, 5,));
}

static function foobar(
a:Int,
b:Int,
):Void {}
}

enum Foo {
Bar(
a:Int,
b:Int,
);
}

function moduleFoobar(
a:Int,
b:Int,
):Int {
return a + b;
}
6 changes: 6 additions & 0 deletions tests/misc/projects/trailing-commas/Main2.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class Main2 {
static function f(t:Type.ValueType, t2:Type.ValueType,,) {}
public static function main():Void {
f(TNull,TNull,);
}
}
2 changes: 2 additions & 0 deletions tests/misc/projects/trailing-commas/compile1.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--main Main
--interp
1 change: 1 addition & 0 deletions tests/misc/projects/trailing-commas/compile1.hxml.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Main.hx:22: 15
2 changes: 2 additions & 0 deletions tests/misc/projects/trailing-commas/compile2-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--main Main2
--interp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Main2.hx:2: characters 56-57 : Unexpected ,

0 comments on commit 78d6f2a

Please sign in to comment.