Add captures-cast-to-interface test; document imported-object cast bugs#255
Merged
Merged
Conversation
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>
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
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.capturedfield, no per-cast heap patch.--emit=mlirconfirms only onets.New(boxing the literal) and a constantSymbolRefOpin 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 atMLIRGenInterfaces.cpp:312when the export has no explicit type annotation (the cross-module declaration-export mechanism degrades an inferred object-literal type to bareobjecton reimport, losing its structural shape).llvm_unreachable("review usage")in the generic cast lowering atCastLogicHelper.h:765when the export is instead given an explicit structural type annotation (avoids the degradation above, but the literal no longer boxes asObjectType, 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
@dllimportboundaries, and the generic cross-type-system cast lowering) for a future, separate investigation.Test plan
00interface_captures.ts, both AOT and JITctest -C Debug- 720/720 passed, no regressions🤖 Generated with Claude Code