Repository navigation
Fix exported resource methods with arguments - #76
Merged
andreiltd merged 1 commit intoAug 31, 2026
Merged
Conversation
Read the resource receiver from the first lowered argument instead of popping the final method argument. Extend the exported resource regression to prove scalar and variant arguments reach JavaScript in order. Tests: cargo test --locked --test wit_types test_exported_resource -- --nocapture
Merged
malformed-c
added a commit
to apsis-io/dwarf
that referenced
this pull request
Sep 2, 2026
An exported resource method took `this` off the END of the argument stack, where the receiver is lowered as the FIRST argument. A method with no arguments works either way, which is why dwarf's existing coverage (`increment()`) never noticed; every method that takes an argument got the last argument as its receiver instead of the resource. Ported rather than cherry-picked: dwarf's `export_call` has diverged too far upstream to merge (string prefixes here, a `classify`/`FuncKind` refactor there), so this is the two-line fix and their test, adapted to dwarf's shape. Confirmed the test fails with `pop_value` restored and passes with `shift_value`. Upstream: andreiltd/componentize-qjs#76 Co-Authored-By: Claude Opus 5 (1M context) <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.
Problem
For exported resource methods, canonical lowering places the resource receiver first and regular method arguments after it. The interpreter currently calls pop_value for the receiver, so any method with arguments removes the final argument and treats it as self. No-argument methods work, while scalar and variant arguments trap before the JavaScript method body.
Fix
Add a QjsCallContext operation that shifts the first stack value and use it for method receivers. The remaining argument values keep their existing order when drained into the JavaScript call.
Extend test_exported_resource with both a scalar method and a variant method, then assert their values are observed in JavaScript.
Test
cargo test --locked --test wit_types test_exported_resource -- --nocapture
Result: 1 passed; 0 failed.