BridgeJS: Fix stack ordering for optional arrays and dictionaries#671
Merged
krodak merged 1 commit intoswiftwasm:mainfrom Feb 22, 2026
Merged
BridgeJS: Fix stack ordering for optional arrays and dictionaries#671krodak merged 1 commit intoswiftwasm:mainfrom
krodak merged 1 commit intoswiftwasm:mainfrom
Conversation
158b64e to
9339c1c
Compare
kateinoigakukun
approved these changes
Feb 22, 2026
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.
Overview
Follow-up to #472 which fixed LIFO stack ordering for multiple stack-based parameters but missed some types.
The
generateParameterLifting()method inExportSwift.swifthandles the case where multiple stack-based parameters appear in a single function - it extracts their pops into reverse-ordered temporaries so each parameter reads its own data from the shared LIFO stacks. The original fix covered.swiftStruct,.associatedValueEnum, and.array, but missed.dictionaryand any.nullable()wrapper around stack-based types (e.g.[Int]?,[String: V]?).This caused a runtime crash when a function had two or more optional array parameters - the first parameter would pop the second parameter's data, leading to type confusion and a wasm trap.
1. Replace hardcoded type matching with
isStackUsingParameterAdded a computed property on
BridgeTypethat recursively identifies stack-using types, including through nullable wrappers. This replaces the incomplete switch statement and won't break when new stack-based types are added.Tests
Added
multiArrayParams(nums:strs:),multiOptionalArrayParams(a:b:), and aMultiArrayContainerclass with a multi-array constructor, plus E2E assertions verifying each parameter receives its own data.