wabt icon indicating copy to clipboard operation
wabt copied to clipboard

Fix parsing for typed function reference types

Open takikawa opened this issue 3 years ago • 3 comments

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.

takikawa avatar Apr 04 '22 23:04 takikawa

Pinging @dbezhetskov in case you have any thoughts on this approach too. :)

takikawa avatar Apr 04 '22 23:04 takikawa

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.

sbc100 avatar Aug 15 '22 22:08 sbc100

@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).

keithw avatar Sep 17 '22 06:09 keithw