Skip to content

Fix DictionaryMember parser to match the WebIDL spec grammar#62

Merged
guybedford merged 1 commit intomasterfrom
fix-dictionary-member-spec-grammar
Feb 26, 2026
Merged

Fix DictionaryMember parser to match the WebIDL spec grammar#62
guybedford merged 1 commit intomasterfrom
fix-dictionary-member-spec-grammar

Conversation

@guybedford
Copy link
Contributor

Summary

  • Fixes the DictionaryMember parser to accept the spec-correct required [ExtAttrs] Type identifier ; syntax, in addition to the existing [ExtAttrs] required Type identifier ; order
  • Replaces the macro-generated parser with a manual Parse implementation that handles both productions from the WebIDL spec grammar
  • Required to unblock Make VideoFrame stable wasm-bindgen#5008, where VideoFrame.webidl uses the spec-correct syntax required [EnforceRange] unsigned long codedWidth;

WebIDL spec grammar

DictionaryMemberRest ::
    required TypeWithExtendedAttributes identifier ;
    Type identifier Default ;

TypeWithExtendedAttributes ::
    ExtendedAttributeList Type

For required members, extended attributes on the type go after required, not before it. The previous parser only accepted them before required.

Backward compatibility

Both orderings are accepted:

  • required [EnforceRange] unsigned long foo; (spec-correct)
  • [EnforceRange] required unsigned long foo; (old weedle order, still supported)

When type-level attributes are present (spec position), they are merged into the attributes field so downstream consumers don't need changes.

The WebIDL spec defines two productions for dictionary members:

  DictionaryMemberRest ::
      required TypeWithExtendedAttributes identifier ;
      Type identifier Default ;

This means for required members, extended attributes like [EnforceRange]
go between 'required' and the type:

    required [EnforceRange] unsigned long codedWidth;

Previously, weedle only accepted the non-spec order:

    [EnforceRange] required unsigned long codedWidth;

This change replaces the macro-generated parser with a manual Parse
implementation that supports both orderings for backward compatibility.

Fixes wasm-bindgen/wasm-bindgen#5008.
@guybedford guybedford merged commit 3e7c8cb into master Feb 26, 2026
2 checks passed
guybedford added a commit to evilpie/wasm-bindgen that referenced this pull request Feb 26, 2026
Bumps weedle to include wasm-bindgen/weedle#62, which fixes parsing of
dictionary members like `required [EnforceRange] unsigned long codedWidth;`
per the WebIDL spec grammar.
guybedford added a commit to evilpie/wasm-bindgen that referenced this pull request Feb 26, 2026
Bumps weedle to include wasm-bindgen/weedle#62, which fixes parsing of
dictionary members like `required [EnforceRange] unsigned long codedWidth;`
per the WebIDL spec grammar.
guybedford added a commit to evilpie/wasm-bindgen that referenced this pull request Feb 27, 2026
Bumps weedle to include wasm-bindgen/weedle#62, which fixes parsing of
dictionary members like `required [EnforceRange] unsigned long codedWidth;`
per the WebIDL spec grammar.
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.

1 participant