Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix: rest parameter crash resolver
  • Loading branch information
Congcong Cai committed Sep 27, 2023
commit 24792b1e5cdef03cefafc8139aea437258de9622
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
16 changes: 16 additions & 0 deletions tests/compiler/issues/2707.debug.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(module
(type $i32_=>_i32 (func (param i32) (result i32)))
(global $issues/2707/func (mut i32) (i32.const 32))
(global $~lib/memory/__data_end i32 (i32.const 44))
(global $~lib/memory/__stack_pointer (mut i32) (i32.const 32812))
(global $~lib/memory/__heap_base i32 (i32.const 32812))
(memory $0 1)
(data $0 (i32.const 12) "\1c\00\00\00\00\00\00\00\00\00\00\00\05\00\00\00\08\00\00\00\01\00\00\00\00\00\00\00\00\00\00\00")
(table $0 2 2 funcref)
(elem $0 (i32.const 1) $start:issues/2707~anonymous|0)
(export "memory" (memory $0))
(func $start:issues/2707~anonymous|0 (param $args i32) (result i32)
i32.const 1
return
)
)
3 changes: 3 additions & 0 deletions tests/compiler/issues/2707.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"asc_flags": []
}
6 changes: 6 additions & 0 deletions tests/compiler/issues/2707.release.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(module
(memory $0 1)
(data $0 (i32.const 1036) "\1c")
(data $0.1 (i32.const 1048) "\05\00\00\00\08\00\00\00\01")
(export "memory" (memory $0))
)
4 changes: 4 additions & 0 deletions tests/compiler/issues/2707.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// should not crash
let func: (...args: i32[]) => i32 = (...args: i32[]) => {
return 1;
};