Skip to content

fix(validator,gc): unreachable stack truncation and GC instruction fixes#157

Merged
avrabe merged 1 commit intomainfrom
fix/wast-conformance-batch2
Mar 15, 2026
Merged

fix(validator,gc): unreachable stack truncation and GC instruction fixes#157
avrabe merged 1 commit intomainfrom
fix/wast-conformance-batch2

Conversation

@avrabe
Copy link
Collaborator

@avrabe avrabe commented Mar 15, 2026

Summary

  • Fix WAST validator to always truncate operand stack after terminating instructions, even in already-unreachable code — values between consecutive unreachable/br/return instructions were accumulating and causing false "type mismatch" at block end
  • Fix ref.eq to handle i31ref (value equality), structref/arrayref (identity comparison), and cross-type null comparisons
  • Fix ref.i31 to use mask (& 0x7FFFFFFF) instead of shift
  • Fix i31.get_s to properly sign-extend from bit 30

Test plan

  • block.wast: 170/223 → 223/223 (fully passing)
  • loop.wast: 42/121 → 121/121 (fully passing)
  • select.wast: 1/126 → 113/126 (+112)
  • i31.wast: 0/73 → 31/73 (+31)
  • Full WAST suite: 62,626 → 62,788 passing (95.7%)

Trace: skip

🤖 Generated with Claude Code

Validator: Always truncate operand stack after terminating instructions
(unreachable, throw, br, return, etc.) even in already-unreachable code.
Previously, values pushed between consecutive terminating instructions
accumulated, causing false "type mismatch" errors at block end.

Fixes select.wast (+125), block.wast (+53), loop.wast (+79) and other
tests with unreachable code patterns.

GC: Fix ref.eq to handle i31ref (value equality), structref/arrayref
(identity comparison), and cross-type null comparisons. Fix ref.i31 to
use mask instead of shift. Fix i31.get_s sign extension from bit 30.

WAST conformance: 62,626 → 62,788 passed (+162), 3,016 → 2,854 failed.

Trace: skip

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@avrabe avrabe merged commit 61c5476 into main Mar 15, 2026
14 checks passed
@avrabe avrabe deleted the fix/wast-conformance-batch2 branch March 15, 2026 12:46
@github-actions
Copy link

🔍 Build Diagnostics Report

Summary

Metric Base Branch This PR Change
Errors 0 0 0
Warnings 2 2 0

🎯 Impact Analysis

Issues in Files You Modified

  • 0 new errors introduced by your changes
  • 0 new warnings introduced by your changes
  • 0 total errors in modified files
  • 0 total warnings in modified files
  • 0 files you modified

Cascading Issues (Your Changes Breaking Other Files)

  • 0 new errors in unchanged files
  • 0 new warnings in unchanged files
  • 0 unchanged files now affected

Note: "Cascading issues" are errors in files you didn't modify, caused by your changes (e.g., breaking API changes, dependency issues).

✅ No Issues Detected

Perfect! 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

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