feat: add support for tail calls by JairusSW · Pull Request #3020 · AssemblyScript/assemblyscript · GitHub
Skip to content

feat: add support for tail calls#3020

Draft
JairusSW wants to merge 4 commits intoAssemblyScript:mainfrom
JairusSW:tail-call
Draft

feat: add support for tail calls#3020
JairusSW wants to merge 4 commits intoAssemblyScript:mainfrom
JairusSW:tail-call

Conversation

@JairusSW
Copy link
Copy Markdown
Contributor

@JairusSW JairusSW commented Apr 24, 2026

This PR adds basic support for the Tail Call Proposal behind the --enable tail-calls flag.

Currently, it only detects direct return call() statements. I'll go ahead and support call_indirect along with some other things later.

Roadmap:

  • return call() statements
  • return call_indirect(...) statements
  • Tail positions inside control flow (if/else, switch, ternary) where each terminating branch returns a call
  • Tail positions through expression wrappers that preserve tail semantics (e.g. block-wrapped return values)
  • Indirect forms (const x = call(...); return x;) when no semantic changes can be proven

Oh forgot to say, I used a LLM to scaffold initial tests. Typically I use like foo1, foo2, etc.. so this time you get nice names lol. That being said, it did miss a lot of tests i'd like to add, so I'll be adding them. The current tests are sufficient for now though

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

@JairusSW
Copy link
Copy Markdown
Contributor Author

JairusSW commented Apr 24, 2026

@JairusSW JairusSW changed the title feat: add support feat: add support for tail calls Apr 24, 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.

1 participant