Skip to content

A rest parameter of a primitive type is an error at the parameter - #589

Merged
ASDAlexander77 merged 1 commit into
mainfrom
rest-parameter-type-error
Oct 17, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
rest-parameter-type-error

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

function f(...a: int) {}; f(1, 2); reached the MLIR verifier: 'ts.CreateArray' op result #0 must be ..., but got 'si32' at the call, then module verification error at 1:1.

Fix: a declared rest parameter of a number, string, boolean, bigint or char type is an error at the parameter: A rest parameter must be of an array type, not 's32'. Arrays, tuples, any and generic rest parameters (...args: TS) are left as they were. Function types ((...args: any) => any) go through another path and are not changed.

Repro (diagnostic-location/rest_parameter_type.ts):

function sum(...a: int[]) {}

function f(...a: int) {}   // 6:12: error: A rest parameter must be of an array type, not 's32'

function main() {
    sum(1, 2);
    f(1, 2);
}

The test fails on any "verification" text or a 1:1 location.

ctest -C Release -j 8 --timeout 300: 100% passed, 0 failed (4092 tests on this branch).

🤖 Generated with Claude Code

`function f(...a: int) {}; f(1, 2);` reached the MLIR verifier:
"'ts.CreateArray' op result #0 must be ..." at the call, then "module
verification error" at 1:1. The arguments a rest parameter takes are
put in an array, so TypeScript requires an array type; tslang now
rejects a number, string, boolean, bigint or char one at the
parameter. Arrays, tuples, any and generic rest parameters are left
as they were.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 9af4984 into main Oct 17, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the rest-parameter-type-error branch October 17, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant