Skip to content

feat: multi-value support (and tuples too i suppose)#3016

Draft
JairusSW wants to merge 6 commits intoAssemblyScript:mainfrom
JairusSW:main
Draft

feat: multi-value support (and tuples too i suppose)#3016
JairusSW wants to merge 6 commits intoAssemblyScript:mainfrom
JairusSW:main

Conversation

@JairusSW
Copy link
Copy Markdown
Contributor

@JairusSW JairusSW commented Apr 22, 2026

Fixes #1633

This PR adds basic support for the Multi Value Proposal. Some of the major changes are:

  • Adds TupleTypeNode to the AST
  • Parser now parses TupleTypeNode
  • Supports --enable multi-value to cli and features
  • Instead of a single returnType: Type, we now generally accept returnTypes: Type[] across the board
  • Added an explicit resolveReturnTypes() method that essentially walks all types within the tuple and delegates it to resolveType()

I need to add some more tests and probably should wait until binaryen is updated before taking this off draft

I did notice that running wat2wasm on generated .wat will not compile because binaryen uses a tuple type that is not in the WAT spec. I'm assuming that the output of --textFile shouldn't necessarily need to be valid WAT?

I did utilize Claude to make an outline plan for implementation which I referenced. I had it trace other features and document what files need to be modified. Really helped with such a large codebase

I intentionally tried to modify as little as possible in this PR while still making it somewhat complete. If you have time while it's still in draft phase, I'd appreciate some basic feedback to make sure I'm going in the right direction here rather than correcting something later on which just requires more time for everyone.

Here's a sort of roadmap for this PR:

  • Allow functions to return correct multi-values through binaryen
  • Allow tuples to be indexed properly
    • Index with compile time constant
    • Index at runtime with bounds checking
    • Support unchecked()??
  • Allow tuples to be assigned to locals
    • Function locals
    • Global locals
  • Allow tuples to be ingested as parameters
  • Allow tuples to be destructured properly

Let me know if there's anything i missed here

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

@JairusSW JairusSW changed the title Multi-value support feat: multi-value support Apr 22, 2026
@JairusSW JairusSW changed the title feat: multi-value support feat: multi-value support (and tuples too i suppose) Apr 22, 2026
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.

Multi-value support?

1 participant