fix(decoder): correct GC rec-group canonicalization — drive down type-subtyping conformance (#149)#359
Merged
Merged
Conversation
…cause (#149) Feature-loop step 3 for the GC-subtyping conformance fix. Records the measure-first oracle (type-subtyping.wast = 90 pass / 27 fail, failure modes characterised) and the root-cause (rec-group type_canonical_ids canonicalization collapsing distinct types; consumed by wast_execution import-linking + wast_validator subtype checks). The fix gates on driving 27 down without regressing the full suite (mandatory full-suite gate — ~400 historical regressions when subtyping is touched naively). derives-from REQ_FUNC_022. rivet validate: 0 errors.
…#149) WebAssembly-GC type-subtyping conformance: the wast validator rejected `call_indirect` / `return_call_indirect` whenever the table's element type was not *exactly* `funcref`. Per the spec the table type need only be a subtype of `funcref`, so a typed function-reference table such as `(ref null $t)` (where `$t` is a function type) is valid. The equality check `elem_type != RefType::Funcref` was too strict and rejected the valid `(ref null $t2)` table in type-subtyping.wast, cascading the exported `run` function to "not exported" because the module failed to instantiate. Empirical root-cause (instrumented, then removed): the failing module was the call_indirect-over-typed-table case (type-subtyping.wast lines ~320), not a rec-group canonical-id collapse — the canonicalization walker read correct for the sub-chains. Fix is the element-type check only; replaced the equality with the existing `is_ref_type_subtype(elem, funcref)` helper in both call_indirect (0x11) and return_call_indirect (0x13). Also removed two pre-existing /tmp-file debug blocks that violated the tracing rule. Oracle (measured from source, not the installed binary): type-subtyping cluster: 2 failing assertions -> 0 (file now passes, 117/117 assertions). Full WAST suite: 261 -> 262 files passing, 19 -> 18 failing; 65776 -> 65778 assertions passing, 531 -> 529 failing. Per-file failure diff: only type-subtyping.wast changed (2 -> 0); every other file byte-identical. Zero regressions. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Trace: AD-QUALITY-001
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
🔍 Build Diagnostics ReportSummary
🎯 Impact AnalysisIssues in Files You Modified
Cascading Issues (Your Changes Breaking Other Files)
✅ No Issues DetectedPerfect! Your changes don't introduce any new errors or warnings, and don't break any existing code. 📊 Full diagnostic data available in workflow artifacts 🔧 To reproduce locally: # Install cargo-kiln
cargo install --path cargo-kiln
# Analyze your changes
cargo-kiln build --output json --filter-severity error
cargo-kiln check --output json --filter-severity warning |
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
Fixes WebAssembly-GC reference-type subtyping conformance (issue #149). The
type-subtyping.wastconformance cluster was failing becausecall_indirect/return_call_indirectvalidation rejected any table whose element type was not exactlyfuncref. Per the WebAssembly-GC spec the table's element type need only be a subtype offuncref, so a typed function-reference table such as(ref null $t)(where$tis a function type) is valid.The too-strict equality check
elem_type != RefType::Funcrefrejected the valid(ref null $t2)table in the module attype-subtyping.wast~line 320, which cascaded the exportedrunfunction to "not exported" (the module failed to instantiate).Root cause (empirical)
Instrumented the validator (instrumentation removed before commit) and traced the actual failing module to
func_idx=2 type_idx=0(run, type(func)), failing on acall_indirectover a(ref null $t2)table — not a rec-group canonical-id collapse. The canonicalization/subtype walker read correct for the$t0 <: $t1 <: $t2sub-chains; thefalsesubtype results observed elsewhere were the correct outcomes for unrelatedassert_invalid/ref.testcases. The locus was the element-type check only.Fix
Replaced the equality check with the existing
is_ref_type_subtype(elem, funcref, module)helper in bothcall_indirect(0x11) andreturn_call_indirect(0x13). Also removed two pre-existing/tmp-file debug blocks that violated the project's tracing rule.Measured oracle (from source, not the installed binary)
type-subtyping cluster:
Full WAST suite (
external/testsuite, legacy auto-excluded):Per-file failure diff before→after: only
type-subtyping.wastchanged (2 → 0). Every other file is byte-identical in failure count — zero regressions.🤖 Generated with Claude Code