Fix cross-module multi-method vtable corruption via decl-text object-vs-tuple printing - #263
Merged
Merged
Conversation
…vs-tuple printing
A structurally-typed export's method fields are physically stored as plain
FunctionType (raw 8-byte function pointer), but the decl-text printer
described named-field (object-shaped) types using positional tuple syntax
instead of object syntax, so method fields round-tripped on import as
HybridFunctionType (16-byte {data,func} pair). This added a fixed +8-byte
read-offset drift per method field, corrupting every field after the first
when casting a multi-method structurally-typed cross-module value to an
interface - crashing on a null function pointer call past the second method.
Fix: printType now prints named-field TupleType/ConstTupleType/ObjectStorageType
via printObjectType (method-signature-friendly) instead of printTupleType
whenever every field has a real id, matching the pre-existing (but previously
unapplied) diagnosis already documented in printFields' own comment.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This was referenced Jul 20, 2026
ASDAlexander77
added a commit
that referenced
this pull request
Jul 20, 2026
…ods (#264) export_object_literal_untyped.ts only ever exercised a single method (inc()) on a boxed ObjectType import. Adds a genuinely multi-method variant (add/ addTwice/scaled), covering both direct calls on the boxed global and an interface cast of it - a combination only made correct by the decl-text object-vs-tuple printer fix (#263), not previously tested. 736/736 suite. 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
FunctionType(a raw 8-byte function pointer —this/the object is implicit via the container). The cross-module declaration-text printer (MLIRPrinter.h) described named-field (object-shaped) types using positional tuple syntax ([name: (args) => result]) instead of object syntax ({name(args): result}), so method fields round-tripped on import as the widerHybridFunctionType(16-byte{data,func}pair) instead of matching the exporter's actual storage.printType's dispatch forTupleType/ConstTupleType/ObjectStorageTypenow callsprintObjectType(method-signature-friendly) instead ofprintTupleTypewhenever every field has a realid(i.e. the type is object-shaped, not a positional tuple) — matching the pre-existing diagnosis already documented inprintFields's own comment, just not previously wired up.Test plan
export/import_object_literal_structural_typed_multi_method.ts(3-method interfaceadd/addTwice/scaled), bothtest-compile-shared-...andtest-jit-shared-...variants — verifies correct values end-to-end (3/7/14) where it previously crashed on the third methoddocs/interface-vtable-simplification-design.mdto record the real root cause (the design doc's earlier "candidates worth checking" — vtable-patch-loop ordering, undersized heap clone — were both ruled out; this bug was upstream of that code entirely)🤖 Generated with Claude Code