You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Should zero-length groups of compact imports be allowed?
Currently there is nothing in the spec or overview to indicate otherwise. From a semantic point of view it seems reasonable. However, it does have a couple implications that may be worth discussing.
For example, the existence of empty groups means that we can no longer immediately reject a module if the number of import groups (formerly single imports) is greater than 1 million. Instead we must actually parse all imports and bail out on the 1,000,001'th import.
Additionally, the second compact encoding declares an externtype that may well end up going unused if empty groups are allowed. This is strange and may cause issues for parsers if they perform any side effects or track any metadata while parsing types. (SpiderMonkey falls into this category; we have hacked around it for now until this is resolved.)
On the other hand, it seems that rec groups cause a similar situation for the type section. But presumably we are ok with that, and we explicitly test for that. Should we assume the same for the import section?
Wasm consistently allows zero-size for all lists, such as sections, locals, etc. Situations like unused types already exist for locals, too, so it's difficult to argue that there should be an exception here. Do we care about failing fast(er) on malformed modules?
Perhaps not, it was just a change that stood out to me while implementing it in SpiderMonkey. The locals thing is a good point. Allowing zero seems the most reasonable overall to me.
Activity
rossberg commentedon Jan 15, 2026
Wasm consistently allows zero-size for all lists, such as sections, locals, etc. Situations like unused types already exist for locals, too, so it's difficult to argue that there should be an exception here. Do we care about failing fast(er) on malformed modules?
bvisness commentedon Jan 15, 2026
Perhaps not, it was just a change that stood out to me while implementing it in SpiderMonkey. The locals thing is a good point. Allowing zero seems the most reasonable overall to me.
bvisness commentedon Jan 16, 2026
Actually, reopening because I should add spec tests for this. Apologies for the noise.