Skip to content

Zero-length import groups? #15

Closed
Closed

Description

@bvisness

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?

Activity

  1. rossberg commented on Jan 15, 2026

    @rossberg
    Member

    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?

  2. bvisness commented on Jan 15, 2026

    @bvisness
    CollaboratorAuthor

    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.

  3. bvisness commented on Jan 16, 2026

    @bvisness
    CollaboratorAuthor

    Actually, reopening because I should add spec tests for this. Apologies for the noise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions