Fixes #3929 Allow exporting functions named "default". (#3930)

This commit is contained in:
Nicklas Warming Jacobsen
2024-05-27 22:38:45 +02:00
committed by GitHub
parent b4da51c4b1
commit 5767be9ea0
3 changed files with 12 additions and 1 deletions

View File

@@ -5,6 +5,10 @@
### Added
* Allow exporting functions named `default`. Throw error in wasm-bindgen-cli if --target web and
an exported symbol is named `default`.
[#3930](https://github.com/rustwasm/wasm-bindgen/pull/3930)
* Added support for arbitrary expressions when using `#[wasm_bindgen(typescript_custom_section)]`.
[#3901](https://github.com/rustwasm/wasm-bindgen/pull/3901)

View File

@@ -327,6 +327,13 @@ impl Bindgen {
.context("failed getting Wasm module")?,
};
// Check that no exported symbol is called "default" if we target web.
if matches!(self.mode, OutputMode::Web)
&& module.exports.iter().any(|export| export.name == "default")
{
bail!("exported symbol \"default\" not allowed for --target web")
}
let thread_count = self
.threads
.run(&mut module)

View File

@@ -799,7 +799,7 @@ impl ConvertToAst<BindgenAttrs> for syn::ItemFn {
false,
None,
false,
None,
Some(&["default"]),
)?;
attrs.check_used();
Ok(ret.0)