Repository navigation
Infer a generic class from overloaded and rest constructors; test the default library under every model - #715
Merged
Conversation
…I tests the default library under every model `new Array(10, 20, 30)` against DefaultLib's Array<T> with three constructors (`data: T[]`, `count: int`, `...args: T[]`) stayed the unspecialized Array: inferClassTypeFromConstructorArguments gave up on any class with more than one constructor, and skipped rest parameters. It now tries the constructors that can take that many arguments in declaration order, takes T from every argument a rest parameter collects, and the first that gives every type argument answers. CI built the default library for gc, rc, none and own but tested only gc: the Test Default Library steps (Windows and Linux) now run tests.ps1 / tests.sh for each model, every model before a failure fails the step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generic class inferred through overloaded and rest constructors
new Array(10, 20, 30), against DefaultLib'sArray<T>with three constructors(
data: T[] = [],count: int = 0,...args: T[]), stayed the unspecializedArray("Class member 'length' can't be found").
inferClassTypeFromConstructorArguments:It now tries the constructors that can take that many arguments, in declaration order;
a rest parameter takes
Tfrom every argument it collects; the first constructor thatgives every type argument answers.
new Array(10, 20, 30)isArray<si32>.Test:
List<T>(array constructor + rest constructor) added to00generic_class_constructor_inference.ts; it fails without the fix.CI: default library tests under every memory model
The library was built for gc, rc, none and own, but
Test Default Libraryran only gc.Both steps (Windows
tests.ps1, Linuxtests.sh) now run each model; on Windows each inits own
pwsh, sincetests.ps1reads the library paths once at its start. Every modelruns before a failure fails the step.
Verification
tests.ps1locally (with DefaultLib's uncommittedArray<T>constructors andthe new
array_constructors_overload.ts): gc, rc, none, own all pass in all four passes.Not in this PR
new Array<int>(10)(and sonew Array(10)) has length 1: withT = intthe call picks(...args: T[])over(count: int).-mm=own:new Array<string>("a", "b")through the rest constructor fails the own checker(
find/findLast/_with);new Array<string>(["a", "b"])works.🤖 Generated with Claude Code