rustwasm / wasm-bindgen

Facilitating high-level interactions between Wasm modules and JavaScript
https://rustwasm.github.io/docs/wasm-bindgen/
Apache License 2.0
7.74k stars 1.07k forks source link

Error regenerating `web-sys` with current WebGPU IDL #2896

Open RSSchermer opened 2 years ago

RSSchermer commented 2 years ago

Describe the Bug

Attempting to rebuild web-sys with the current WebGPU IDL produces an error that seems mistargetted.

Steps to Reproduce

  1. Replace contents of crates/web-sys/webidls/unstable/WebGPU.webidl with https://gpuweb.github.io/gpuweb/#idl-index
  2. cd crates/web-sys
  3. cargo run --release --package wasm-bindgen-webidl -- webidls src/features

Expected Behavior

web-sys is successfully regenerated

Actual Behavior

Error: compiling WebIDL into wasm-bindgen bindings in file "webidls/enabled/BatteryManager.webidl", line 13 column 17

Caused by:
    failed to parse webidl at byte position 35773

Additional Context

The error points to webidls/enabled/BatteryManager.webidl being the problem, however, running cargo run --release --package wasm-bindgen-webidl -- webidls src/features without first updating webidls/unstable/WebGPU.webidl does not result in an error and successfully regenerates web-sys. webidls/unstable/WebGPU.webidl is the only files that is modified, webidls/enabled/BatteryManager.webidl is untouched, so I would assume the problem is with the current WebGPU IDL. I however am not really sure how to proceed with debugging this error.

RSSchermer commented 2 years ago

This is (partially?) resolved by https://github.com/rustwasm/wasm-bindgen/pull/2907. There is potentially still a remaining issue concerning the code-span targetting of the error message; the problem definitely originated in webidls/unstable/WebGPU.webidl, not in webidls/enabled/BatteryManager.webidl. That is however a comparatively minor issue that may not pop-up again until more new features are added to the WebIDL spec. I'm not quite sure whether to leave this issue open, or whether this isn't worth digging into and closing it here.

alexcrichton commented 2 years ago

If you can still reproduce the error message (in a different manner perhaps) I think it might be good to log an issue about that. I know there's some internal trickery about concatenating sources and dealing with spans and it sounds like the bug is in there. If you can't easily reproduce though I think this is fine to close.