Skip to content

Add captures-cast-to-interface test; document imported-object cast bugs#255

Merged
ASDAlexander77 merged 1 commit into
mainfrom
interface-vtable-test-matrix-followup
Jul 19, 2026
Merged

Add captures-cast-to-interface test; document imported-object cast bugs#255
ASDAlexander77 merged 1 commit into
mainfrom
interface-vtable-test-matrix-followup

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

Closes out the two test-matrix gaps left open by #253/#254 (docs/interface-vtable-simplification-design.md §7):

  • Captures-bearing object-literal method cast to an interface (00interface_captures.ts): confirms the constant-vtable path (§3) handles captures correctly - one shared function symbol per literal expression, per-instance state in a separate .captured field, no per-cast heap patch. --emit=mlir confirms only one ts.New (boxing the literal) and a constant SymbolRefOp in the vtable slot.

  • Casting an imported (cross-module) object value to an interface inside the importing module: attempting to actually write this test surfaced two separate pre-existing bugs, unrelated to the Make interface vtable slot numbering a single source of truth #253/Constant vtables for object-literal methods, skipping the per-cast heap patch #254 changes, that make the scenario not work at all today regardless of how the value is exported:

    • mlir::cast<mlir_ts::TupleType> assertion at MLIRGenInterfaces.cpp:312 when the export has no explicit type annotation (the cross-module declaration-export mechanism degrades an inferred object-literal type to bare object on reimport, losing its structural shape).
    • llvm_unreachable("review usage") in the generic cast lowering at CastLogicHelper.h:765 when the export is instead given an explicit structural type annotation (avoids the degradation above, but the literal no longer boxes as ObjectType, and the resulting cross-module tuple value can't be cast to a method-bearing interface).

    No test was added for this (a test expected to crash doesn't belong in the regression suite); both findings are documented in the design doc as a distinct, deeper bug area (object-literal type export/reimport across @dllimport boundaries, and the generic cross-type-system cast lowering) for a future, separate investigation.

Test plan

  • New regression test 00interface_captures.ts, both AOT and JIT
  • Full suite: ctest -C Debug - 720/720 passed, no regressions

🤖 Generated with Claude Code

Closes out the two test-matrix gaps from
docs/interface-vtable-simplification-design.md §7:

- Captures-bearing object-literal method cast to an interface
  (00interface_captures.ts): confirms the constant-vtable path (§3) handles
  captures correctly - one shared function symbol per literal expression,
  per-instance state in a separate .captured field, no per-cast heap patch.

- Casting an imported (cross-module) object value to an interface inside the
  importing module: attempting to write this test surfaced two separate
  pre-existing bugs, unrelated to this arc's changes, that make the scenario
  not work at all today regardless of how the value is exported - an
  mlir::cast<TupleType> assertion (MLIRGenInterfaces.cpp:312) when the
  export has no type annotation and degrades to a bare `object` type on
  reimport, and an llvm_unreachable("review usage") in the generic cast
  lowering (CastLogicHelper.h:765) when the export is given an explicit
  structural type instead. No test added (would just crash); both findings
  are documented in the design doc as a distinct, deeper bug area for future
  investigation, out of scope for this arc.

720/720 full suite green.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit b11b684 into main Jul 19, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the interface-vtable-test-matrix-followup branch July 19, 2026 15:02
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