Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try to fix js_name error when both getter and setter used #2074

Merged
merged 2 commits into from
Apr 10, 2020

Conversation

a1trl9
Copy link
Contributor

@a1trl9 a1trl9 commented Apr 7, 2020

Related to #2072

The error may come from Line 492 in codegen.rs:

        (quote! {
            #(#attrs)*
            #[allow(non_snake_case)]
            #[cfg_attr(
                all(target_arch = "wasm32", not(target_os = "emscripten")),
                export_name = #export_name, // this line...
            )]
            #[allow(clippy::all)]
            pub extern "C" fn #generated_name(#(#args),*) -> #projection::Abi {
                #start_check
                // Scope all local variables to be destroyed after we call the
                // function to ensure that `#convert_ret`, if it panics, doesn't
                // leak anything.
                let #ret = {
                    #(#arg_conversions)*
                    #receiver(#(#converted_arguments),*)
                };
                #convert_ret
            }
        })
        .to_tokens(into);

When both getter and setter are used, a name conflict occurs since export_name for both are the same.

@alexcrichton
Copy link
Contributor

Thanks! Could a test be added for this as well?

@a1trl9
Copy link
Contributor Author

a1trl9 commented Apr 10, 2020

@alexcrichton 6 tests added for wasm::getters_and_setters as follows:
8 - no getter/setter field name, same js_name, different rust name.
9 - no getter/setter field name, same js_name, same rust name (except set prefix).
10 - same getter/setter field name, same js_name, different rust name.
11 - different getter/setter field name, samd js_name, different rust name.
12 - same getter/setter field name, same js_name, same rust name (except set prefix).
13 - different getter/setter field name, samd js_name, same rust name (except set prefix).

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.

2 participants