Skip to content

Array<T>: count and rest constructors - #53

Merged
ASDAlexander77 merged 1 commit into
mainfrom
array-constructor-overloads
Oct 28, 2026
Merged

ASDAlexander77 merged 1 commit into
mainfrom
array-constructor-overloads

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Array: count and rest constructors

Beside constructor(private data: T[] = []), Array<T> gets

  • constructor(count: int = 0): new Array<number>(10) has ten elements;
  • constructor(...args: T[]): new Array(10, 20, 30) is those three, T inferred.

Test: tests/array_constructors_overload.ts.

Needs the compiler

Verification

Locally, tests.ps1 with the compiler of #716: gc, rc, none and own all pass in all four
passes (release/debug, compile/JIT).

Known gap

-mm=own: new Array<string>("a", "b") through the rest constructor fails the own checker
(find/findLast/_with); new Array<string>(["a", "b"]) works. Not exercised by the test.

🤖 Generated with Claude Code

`new Array<number>(10)` makes ten elements and `new Array(10, 20, 30)` those three,
beside `new Array([..])`. Needs the compiler's constructor-overload inference (#715)
and optional-parameter overload fit (#716).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 362f556 into main Oct 28, 2026
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