Skip to content

feat: multi-value returns#3021

Draft
JairusSW wants to merge 6 commits into
AssemblyScript:mainfrom
JairusSW:main
Draft

feat: multi-value returns#3021
JairusSW wants to merge 6 commits into
AssemblyScript:mainfrom
JairusSW:main

Conversation

@JairusSW
Copy link
Copy Markdown
Contributor

@JairusSW JairusSW commented Apr 27, 2026

This PR adds basic support for the Multi-Value Proposal. For a tuple type to be considered for multi-value, it must be explicitly marked with readonly first.

Related: #1633 #1425

So far, this adds basic compiler/binaryen support for outputting multi-value returns, but does not support things like indexing yet

I'm thinking that the next PR should add support type checking for tuples/multi-values, support indexing, and add an SROA pass to identify array literals vs tuples. After that, full support for tuples probably based off of warpo's implementation

  • I've read the contributing guidelines
  • I've added my name and email to the NOTICE file

@JairusSW JairusSW changed the title feat: add initial support for multi-value returns feat: multi-value returns Apr 27, 2026
@MaxGraey
Copy link
Copy Markdown
Member

The more I think about tuples in AS the more I lean toward the idea that semantically, when we declare [T, U, ...] it should be readonly by default and maybe even implicitly so. Ofc that would be a deviate from TypeScript but we are already stricter than TS in many ways. The reason is that tuples should always be passed by value and never by reference. That is how it is done in all languages, and it greatly simplifies lowering to WebAssembly.

Unfortunately, the relevant JS proposal has been abandoned and archived: https://github.com/tc39/proposal-record-tuple

But in our case we still have the hint from the types! It would be more correct to always use readonly [T, U...] but having to write and read that every time and then run into compiler errors saying that tuples must be readonly kw would just be annoying and confusing

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.

2 participants