Skip to content

Commit

Permalink
fix: rest parameter crash resolver (#2748)
Browse files Browse the repository at this point in the history
Fixes #2707
  • Loading branch information
HerrCai0907 authored Oct 7, 2023
1 parent a27258d commit e3e4166
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ export class Resolver extends DiagnosticEmitter {
break;
}
case ParameterKind.Rest: {
assert(i == numParameters);
assert(i == numParameters - 1);
hasRest = true;
break;
}
Expand Down
7 changes: 7 additions & 0 deletions tests/compiler/issues/2707.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"asc_flags": [],
"stderr": [
"AS100: Not implemented: Rest parameters",
"func(1, 2, 3, 4);"
]
}
6 changes: 6 additions & 0 deletions tests/compiler/issues/2707.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// should not crash
let func: (...args: i32[]) => i32 = (...args: i32[]) => {
return 1;
};

func(1, 2, 3, 4);

0 comments on commit e3e4166

Please sign in to comment.