Skip to content

Add overloads - #774

Draft
bvisness wants to merge 3 commits into
WebAssembly:mainfrom
bvisness:overloads
Draft

bvisness wants to merge 3 commits into
WebAssembly:mainfrom
bvisness:overloads

Conversation

@bvisness

@bvisness bvisness commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Adds support for function overloading. The design of overloads changed a bit to have optional suffixes of the form #foo, which can be applied to any function (except getters and setters).

Although I would consider this code fairly complete, I'm actually not sure overloads are a worthwhile feature in the component model. I personally wouldn't be super comfortable landing this until we're farther along in our web preview efforts and have more evidence that it would benefit developers.

Resolves #742, depends on #766.


I chose to use #foo syntax for overload suffixes, because the rules for name uniqueness and parsing just got more confusing and ambiguous when I tried to stick with .foo. (There was a lot of dot-counting, and fussy rules like "if the name has the [method] attribute, get the third label, else get the second label".)

Also, name uniqueness got more complicated. It used to be that strong uniqueness could be computed by just canonicalizing names and chucking them into a hash set. But overloads inherently cause problems with this whole approach. Suppose we have foo-bar, foo#bar, and [method]foo.foo. foo-bar and foo#bar should clearly conflict, as should foo#bar and [method]foo.foo. But foo-bar and [method]foo.foo should not! The problem is that foo-bar and foo#bar conflict on their fully-qualified names, while foo#bar and [method]foo.foo conflict on their base names. If we are going to avoid practical problems for bindings generators, the strong uniqueness algorithm needs to incorporate both.

I won't recap exactly how I reconciled this here, since it's pretty detailed in the patch, but I did my best to ensure that it could still be implemented very simply and efficiently, and still with an algorithm based on name canonicalization.

Just a bunch of drive-by updates made as part of union/overload work.
@bvisness bvisness mentioned this pull request Nov 25, 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.

Function overloading to support common web APIs

1 participant