diff --git a/crates/wasm-bindgen-macro/src/lib.rs b/crates/wasm-bindgen-macro/src/lib.rs index ea65d320..bab7db43 100644 --- a/crates/wasm-bindgen-macro/src/lib.rs +++ b/crates/wasm-bindgen-macro/src/lib.rs @@ -169,7 +169,7 @@ fn bindgen(export_name: &syn::Lit, args.push(my_quote! { #ident: #i }); } ast::Type::BorrowedStr => { - malloc = !MALLOC_GENERATED.swap(true, Ordering::SeqCst); + malloc = malloc || !MALLOC_GENERATED.swap(true, Ordering::SeqCst); let ptr = syn::Ident::from(format!("arg{}_ptr", i)); let len = syn::Ident::from(format!("arg{}_len", i)); args.push(my_quote! { #ptr: *const u8 }); @@ -182,7 +182,7 @@ fn bindgen(export_name: &syn::Lit, }); } ast::Type::String => { - malloc = !MALLOC_GENERATED.swap(true, Ordering::SeqCst); + malloc = malloc || !MALLOC_GENERATED.swap(true, Ordering::SeqCst); let ptr = syn::Ident::from(format!("arg{}_ptr", i)); let len = syn::Ident::from(format!("arg{}_len", i)); args.push(my_quote! { #ptr: *mut u8 }); diff --git a/tests/simple.rs b/tests/simple.rs index 1a8e4d25..74eedfad 100644 --- a/tests/simple.rs +++ b/tests/simple.rs @@ -48,14 +48,14 @@ fn string_arguments() { use wasm_bindgen::prelude::*; wasm_bindgen! { - pub fn assert_foo(a: &str) { - assert_eq!(a, "foo"); - } - pub fn assert_foo_and_bar(a: &str, b: &str) { assert_eq!(a, "foo2"); assert_eq!(b, "bar"); } + + pub fn assert_foo(a: &str) { + assert_eq!(a, "foo"); + } } "#) .file("test.js", r#"