Fix cross-module interface indexer printer gap and add coverage#284
Merged
ASDAlexander77 merged 1 commit intoJul 22, 2026
Merged
Conversation
cross-module-class-indexer-shared-gap-fix.md flagged interfaces as likely sharing the same latent DeclarationPrinter gap as classes did for index signatures, untested because no cross-module interface-indexer test existed. It did: DeclarationPrinter::print(InterfaceInfo::TypePtr) never re-emitted an interface's index signature ([x: T]: U;) for -shared reimport, so a reimporting module's InterfaceInfo::indexes stayed empty and casting to the interface then indexing it failed with "indexer is not declared" / "Interface member '.index' can't be found". Printing it uncovered a second, narrower bug: an interface's index signature FunctionType carries a leading opaque `this` input (added via getInterfaceMethodNameAndType's funcGenContext.thisType, unlike a class's plain (arg)->result index signature), so naively reusing input(0) as the index-argument type printed the wrong type and crashed an unrelated assert in getIndexSignatureArgumentAndResultTypes on reimport. Fixed by picking input(1) when the signature has more than one input, matching that helper's own "first parameter is Opaque" branch. Unlike the class case (PR #283), no isDynamicImport fallback was needed here - interface method dispatch (including the indexer's synthesized get/set) already goes through vtable slots rather than statically-linked symbols, so AOT -shared linking was never an issue once the printer emitted the signature. New export_interface_indexer.ts/import_interface_indexer.ts cross-module test pair (compile, -shared compile, -jit -shared tiers). 799/799 green. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
ASDAlexander77
deleted the
fix/cross-module-interface-indexer-printer-gap
branch
July 22, 2026 23:38
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.
Summary
DeclarationPrintergap classes had for index signatures - untested, since no cross-module interface-indexer test existed to trigger it.DeclarationPrinter::print(InterfaceInfo::TypePtr)never re-emitted an interface's index signature ([x: T]: U;) for-sharedreimport, so casting a class to a cross-module interface and indexing through it failed withindexer is not declared/Interface member '.index' can't be found.FunctionTypecarries a leading opaquethisinput (added viagetInterfaceMethodNameAndType'sfuncGenContext.thisType, unlike a class's plain(arg)->resultsignature) - naively reusinginput(0)as the index-argument type printed the wrong type and crashed an unrelated assert ingetIndexSignatureArgumentAndResultTypeson reimport. Fixed by pickinginput(1)when the signature has more than one input, matching that helper's own "first parameter is Opaque" branch.isDynamicImportfallback was needed - interface method dispatch (including the indexer's synthesizedget/set) already goes through vtable slots rather than statically-linked symbols, so AOT-sharedlinking was never an issue once the printer emitted the signature.Test plan
export_interface_indexer.ts/import_interface_indexer.tscross-module pair, 3 tiers:test-compile-export-import-interface-indexer,test-compile-shared-export-import-interface-indexer,test-jit-shared-export-import-interface-indexerctest -C Debug -j8— 799/799 green (796 previously green + 3 new)🤖 Generated with Claude Code