wabt
wabt copied to clipboard
Fix parsing for typed function reference types
Previously an indexed ref type was parsed as a Var, assuming that regular types would be represented as index vars and indexed ref types would be named vars. The names would be resolved to actual indices later in a separate pass.
Unfortunately, it's also possible for a ref type to be an indexed var that overlaps with a type (e.g., the type "any" which is 0x0 and the index 0 for the type (ref 0)).
This patch fixes the issue by returning both a Type and a Var from ParseValueType.
Edit: I simplified this patch to just solve the issue at hand instead of introducing a bigger re-organization, which I realized was a bad idea.
This PR will close #1881.
Pinging @dbezhetskov in case you have any thoughts on this approach too. :)
I think the idea is that builtin types should all have negative values .. so we know that thing >= to zero is a user type. The fact that we have this internal "Any" think value of zero sounds like a bug.
@takikawa Do you have cycles to respond to this review? Would be nice to get this merged (especially as #1661 is blocked on a bug that this fixes).