Fix cross-module class indexer -shared gap and add coverage#283
Merged
Conversation
super-index-access-gap-fix.md predicted that adding cross-module coverage for class indexers would reproduce the exact 2-bug shape PR #281 fixed for accessors. It did: 1. DeclarationPrinter never re-emitted a class's index signature ([x: T]: U;) when reprinting a -shared @dllimport declaration, so a reimporting module's ClassInfo::indexes stayed empty and `obj[i]`/`super[i]` failed with "Class member '.index' can't be found". 2. ClassIndexAccess had no isDynamicImport fallback (unlike ClassMethodAccess/ClassAccessorAccess), so AOT -shared linking tried to statically resolve the indexer's get/set symbols against an import library that -shared mode never links, failing with "undefined symbol ... dllimport". Routed through the already-existing (but previously unused) ThisIndirectIndexAccessorOp instead, mirroring ClassAccessorAccess's resolveAccessorFunc pattern. New export_class_indexer.ts/import_class_indexer.ts cross-module test pair (compile, -shared compile, -jit -shared tiers). 796/796 green. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2 tasks
ASDAlexander77
added a commit
that referenced
this pull request
Jul 22, 2026
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>
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
DeclarationPrinter::print(ClassInfo::TypePtr)never re-emitted a class's index signature ([x: T]: U;) when reprinting a-shared@dllimportdeclaration, so a reimporting module'sClassInfo::indexesstayed empty andobj[i]/super[i]failed withClass member '.index' can't be found. AddedprintIndexer.ClassIndexAccesshad noisDynamicImportbranch (unlikeClassMethodAccess/ClassAccessorAccess), so AOT-sharedlinking tried to statically resolve the indexer'sget/setsymbols against an import library-sharedmode never links, failing with an undefined-symbol linker error. Routed through the already-existing (but previously unused)ThisIndirectIndexAccessorOp, mirroringClassAccessorAccess's resolver pattern.Test plan
export_class_indexer.ts/import_class_indexer.tscross-module pair, 3 tiers:test-compile-export-import-class-indexer,test-compile-shared-export-import-class-indexer,test-jit-shared-export-import-class-indexerctest -C Debug -j8— 796/796 green (793 previously green + 3 new)🤖 Generated with Claude Code