Skip to content

Fix cross-module interface indexer printer gap and add coverage#284

Merged
ASDAlexander77 merged 1 commit into
mainfrom
fix/cross-module-interface-indexer-printer-gap
Jul 22, 2026
Merged

Fix cross-module interface indexer printer gap and add coverage#284
ASDAlexander77 merged 1 commit into
mainfrom
fix/cross-module-interface-indexer-printer-gap

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

  • cross-module-class-indexer-shared-gap-fix flagged interfaces as likely sharing the same latent DeclarationPrinter gap classes had for index signatures - untested, since no cross-module interface-indexer test existed to trigger it.
  • Bug 1 (printer gap): DeclarationPrinter::print(InterfaceInfo::TypePtr) never re-emitted an interface's index signature ([x: T]: U;) for -shared reimport, so casting a class to a cross-module interface and indexing through it failed with indexer is not declared / Interface member '.index' can't be found.
  • Bug 2 (found while fixing bug 1): 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 signature) - 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 (Fix cross-module class indexer -shared gap and add coverage #283), no isDynamicImport fallback was needed - 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.

Test plan

  • New export_interface_indexer.ts / import_interface_indexer.ts cross-module pair, 3 tiers: test-compile-export-import-interface-indexer, test-compile-shared-export-import-interface-indexer, test-jit-shared-export-import-interface-indexer
  • Full suite: ctest -C Debug -j8 — 799/799 green (796 previously green + 3 new)

🤖 Generated with Claude Code

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
ASDAlexander77 merged commit 0f3677b into main Jul 22, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the fix/cross-module-interface-indexer-printer-gap branch July 22, 2026 23:38
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