Skip to content

Fix subst_externtype matching on incorrect argument types#2120

Merged
rossberg merged 4 commits intoWebAssembly:mainfrom
raoxiaojia:subst_externtype-fix
Mar 24, 2026
Merged

Fix subst_externtype matching on incorrect argument types#2120
rossberg merged 4 commits intoWebAssembly:mainfrom
raoxiaojia:subst_externtype-fix

Conversation

@raoxiaojia
Copy link
Copy Markdown
Contributor

The substitution function for externtype is incorrectly using the substitution for deftype for function externs instead of the intended typeuse, missing the other two cases of typeuse (most importantly typeidx).

The reference interpreter is correct by using subst_typeuse.

The AL interpreter seems to be unaffected because iirc only deftypes exist during actual runtime, and subst_typeuse simply dispatches deftypes using subst_deftype, so this type error is hidden by implicit coercions (either in IL or elaboration), taking the substitution function as deliberately only defined on func externs that are deftypes. Is there something we could do in any of the checks to produce a warning for this kind of scenario (which would have made it obvious)?

For the other part of the tests, module validation should have been affected if generated from the spectec DSL, but that is out of the scope of AL as it focuses on generating the interpreter only and delegates validation etc to the reference interpreter, which is correct on this. Latex backend doesn't seem to print the full substitution definition either. As a result, the prose seems to be the only one that makes this change observable.

There also seems to be some test mismatches under spectec/test-interpreter (I think this is the one for AL?), but those are pre-existing in the current main (probably after #2093 looking at the errors).

Copy link
Copy Markdown
Member

@rossberg rossberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@rossberg
Copy link
Copy Markdown
Member

You'll need to sync wasm-latest. (Tip: make sync-diff in the specification dir usually does the trick.)

@raoxiaojia
Copy link
Copy Markdown
Contributor Author

My local dune test is somehow caching builds a lot for some reason -- this should fix all the test expectations.

@rossberg rossberg merged commit be6efe6 into WebAssembly:main Mar 24, 2026
10 checks passed
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