feat: parse call/construct/index signatures in type literals & class bodies (#121)#124
Merged
Merged
Conversation
…bodies (#121) The interface parser already handles call signatures, construct signatures, and index signatures, but two other parser sites did not — which is where the conformance assignmentCompatibility tests were dying as ParseError. Gap A — inline object type literals (Parser.Types.cs ParseInlineObjectType): - `{ (x: number): void }` — bare call signature - `{ new (x): T }` — construct signature - `{ readonly p: T }` — readonly member modifier ParseInlineObjectTypeInfo recognizes the emitted bare-signature members so they no longer mis-resolve into bogus fields; a pure single call-signature object type resolves to a function type (TypeInfo.Function) and type-checks against function types correctly. Mixed/overloaded/construct cases reach the checker as a Record (signatures dropped, not modeled yet). Gap B — class-body index signatures (Parser.Classes.cs): - `class A { [x: string]: T }` — disambiguated from a computed property name ([expr]:) by an identifier immediately followed by ':'. Parsed so the class body no longer ParseErrors; modeling the index type on the class type is deferred. Baseline (types/conditional + assignmentCompatibility subset): 54 ParseError / 15 Fail / 10 Pass -> 49 ParseError / 18 Fail / 12 Pass (5 tests off ParseError: 2 new passes, 3 now reaching the type checker). Conformance suite green (31/31); no regressions in the core xUnit suite.
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.
Closes #121.
The interface parser already handled call/construct/index signatures, but two other parser sites did not — which is where the conformance
assignmentCompatibilitytests were dying asParseError.Gap A — inline object type literals
Parser.Types.cs(ParseInlineObjectType) +TypeChecker.TypeParsing.cs(ParseInlineObjectTypeInfo):{ (x: number): void }— bare call signature{ new (x): T }— construct signature{ readonly p: T }— readonly member modifierA pure single call-signature object type resolves to a real function type (
TypeInfo.Function) and type-checks against function types correctly. Mixed/overloaded/construct cases reach the checker as aRecord(signatures dropped, not modeled yet — see follow-up #122).Gap B — class-body index signatures
Parser.Classes.cs:class A { [x: string]: T }— disambiguated from a computed property name ([expr]:) by an identifier immediately followed by:, via a save/restore probe. Parsed so the class body no longerParseErrors; modeling the index type on the class type is deferred (follow-up TS Conformance: model class-body index signatures (currently parsed but discarded) #123).Baseline movement
types/conditional+assignmentCompatibilitysubset:54 ParseError / 15 Fail / 10 Pass→49 ParseError / 18 Fail / 12 Pass5 tests off
ParseError(2 new passes, 3 now reaching the type checker). Both new passes verified legitimate (no*.errors.txtbaseline → valid no-error tests).Verification
main— pre-existing/environmental, unrelated to this change.Follow-ups