Skip to content

Extend test coverage for object-literal/interface casts and method dispatch#259

Merged
ASDAlexander77 merged 2 commits into
mainfrom
extend-interface-cast-test-coverage
Jul 19, 2026
Merged

Extend test coverage for object-literal/interface casts and method dispatch#259
ASDAlexander77 merged 2 commits into
mainfrom
extend-interface-cast-test-coverage

Conversation

@ASDAlexander77

Copy link
Copy Markdown
Owner

Summary

Extends test coverage in areas the recent interface-vtable-cast arc (#256-258) never exercised — that arc's tests only ever used zero-argument, single-method interfaces.

  • 00object_annotated_method_params.ts — type-literal-annotated object methods with parameters (the arc's fix, Give type-literal method members an implicit this param so annotated objects keep their receiver #258, only had zero-arg coverage), including a same-module chained sibling-method call (addTwice calling this.add(n)).
  • 00interface_object_array.ts — several distinct object literals (each its own per-type constant vtable) collected into a single interface-typed array and dispatched through the same call site in a loop — catches a shared/aliased-vtable or wrong-this bug that a single-object test can't.
  • export/import_object_literal_structural_typed_params.ts — extends export/import_object_literal_structural_typed.ts (Preserve source field order in the interface-cast object clone #257) along the "zero-arg → parameterized method" axis, cross-module.

Bugs found (documented, not fixed — flagged for follow-up)

Two new, real gaps surfaced while writing these tests, both written up in docs/interface-vtable-simplification-design.md:

  1. Multi-method cross-module vtable slot bug. Casting a cross-module structurally-typed value to a multi-method interface breaks for every vtable slot past 0 — slot 0 works, slot 1 gives a wrong value (no crash), slot 2+ crashes outright. Every prior test in this arc used a single-method interface, so this was never caught. The committed cross-module test deliberately stays single-method to avoid committing a failing case.
  2. (same-module only, unrelated) A value-returning method can't return this.siblingMethod(...) within the same type-literal-annotated object literal (fails to resolve the sibling's type) — calling it as a bare statement works fine. Avoided in the committed tests.

Neither blocks this PR's tests, which are scoped to stay within currently-working behavior.

Test plan

Full ctest suite: 730/730 passed (722 existing + 8 new).

🤖 Generated with Claude Code

ASDAlexander77 and others added 2 commits July 19, 2026 23:15
…spatch

Adds four new test cases exercising variations not covered by the recent
interface-vtable-cast arc (#256-258), which only ever tested zero-argument,
single-method interfaces:

- 00object_annotated_method_params.ts: type-literal-annotated object
  methods with PARAMETERS (that arc's fix only had zero-arg method
  coverage), including a same-module chained sibling-method call.
- 00interface_object_array.ts: several distinct object literals (each its
  own per-type constant vtable) collected into a single interface-typed
  array and dispatched through the same call site in a loop - would catch
  a shared/aliased vtable or wrong-`this` bug that a single-object test
  can't.
- export/import_object_literal_structural_typed_params.ts: extends
  export/import_object_literal_structural_typed.ts's cross-module coverage
  along the "zero-arg -> parameterized method" axis.

Along the way, found and documented (not fixed) two new, real gaps in
docs/interface-vtable-simplification-design.md:
- a cross-module cast to a MULTI-method interface breaks for every vtable
  slot past 0 (wrong value at slot 1, crash at slot 2+) - every prior test
  in this arc only used single-method interfaces, so this was never
  exercised before. The committed cross-module test deliberately stays
  single-method to avoid committing a failing case.
- (same-module only, unrelated) a value-returning method can't `return
  this.siblingMethod(...)` within the same type-literal-annotated object
  literal - calling the sibling as a bare statement works fine. Avoided in
  the committed tests.

Full ctest suite: 730/730 passed (722 + 8 new).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@ASDAlexander77
ASDAlexander77 merged commit 5e995d7 into main Jul 19, 2026
2 checks passed
@ASDAlexander77
ASDAlexander77 deleted the extend-interface-cast-test-coverage branch July 19, 2026 22:37
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