Skip to content

Commit 3245c3c

Browse files
trailing comma fix
1 parent e5b16d4 commit 3245c3c

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ exclude = ["fuzz"]
44

55
[package]
66
name = "tsrun"
7-
version = "0.1.20"
7+
version = "0.1.21"
88
edition = "2024"
99
description = "A TypeScript interpreter designed for embedding in applications"
1010
license = "MIT"
@@ -93,4 +93,4 @@ debug = true
9393
strip = false
9494

9595
[build-dependencies]
96-
trampoline-parser = { version = "0.1.1" }
96+
trampoline-parser = { version = "0.1.2" }

tests/interpreter/function.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,37 @@ fn test_trailing_comma_in_function_call() {
6464
);
6565
}
6666

67+
#[test]
68+
fn test_trailing_comma_in_function_call_multiline() {
69+
// Multiline call with trailing comma
70+
assert_eq!(
71+
eval("function foo(a: string, b: string): string { return a + b; } foo(\n'hello',\n'world',\n)"),
72+
JsValue::from("helloworld")
73+
);
74+
75+
// Full example: object with function expression + multiline call with trailing comma
76+
assert_eq!(
77+
eval(
78+
r#"
79+
export const processor = {
80+
elementHeader: function (element: any): any {
81+
return element;
82+
},
83+
};
84+
function test(a: string, b: string): string {
85+
return foo(
86+
a,
87+
b,
88+
);
89+
}
90+
function foo(a: string, b: string): string { return a + b; }
91+
test("hello", "world");
92+
"#
93+
),
94+
JsValue::from("helloworld")
95+
);
96+
}
97+
6798
#[test]
6899
fn test_function_call() {
69100
assert_eq!(

0 commit comments

Comments
 (0)