swc-project / swc

Rust-based platform for the Web
https://swc.rs
Apache License 2.0
30.99k stars 1.21k forks source link

Why was my function parameter name changed #9556

Closed Zian502 closed 2 weeks ago

Zian502 commented 2 weeks ago

Describe the bug

Create a function expression with the same parameter name as the returned content parameter name. Now, after compiling, the parameter name of the function has been modified

Input code

let (params, values, ) = parse_with_jsx_element(jsx_element);
let group_key = get_key_attribute(jsx_element);
let global_ctxt = SyntaxContext::from_u32(2);

Expr::Call(CallExpr {
        span: DUMMY_SP,
        ctxt: global_ctxt,
        callee: Callee::Expr({
            Box::new(Expr::Member(MemberExpr {
                span: DUMMY_SP,
                obj: Box::new(
                    Expr::Fn(FnExpr {
                        ident: None,
                        function: Box::new(Function {
                            span: DUMMY_SP,
                            params, // With the key of all attributes on the JSX element
                            decorators: Default::default(),
                            body: Some(BlockStmt {
                                span: DUMMY_SP,
                                ctxt: global_ctxt,
                                stmts: vec![Stmt::Return(ReturnStmt {
                                    span: DUMMY_SP,
                                    arg: Some(Box::new(
                                        convert_children_to_expression(
                                            &mut jsx_element.children,
                                            group_key.clone(),
                                        )
                                    )), // Child element With JSX element
                                })],
                            }),
                            ctxt: global_ctxt,
                            is_generator: Default::default(),
                            is_async: Default::default(),
                            type_params: Default::default(),
                            return_type: Default::default(),
                        })
                    })
                ),
                prop: MemberProp::Ident(IdentName {
                    span: DUMMY_SP,
                    sym: Atom::from("call"),
                }),
            }))
        }),
        args: values, // The first element is this, and the remaining elements are the key values of all the attributes on the With JSX element
        type_args: None,
    });

Config

No response

Playground link (or link to the minimal reproduction)

None

SWC Info output

No response

Expected behavior

The parameter name of the function should not be Renaming

Actual behavior

image

Version

swc_core = { version = "=0.97.*", features = ["ecma_plugin_transform"] }

Additional context

No response

github-actions[bot] commented 2 weeks ago

We could not detect a valid reproduction link. Make sure to follow the bug report template carefully.

Why was this issue closed?

To be able to investigate, we need access to a reproduction to identify what triggered the issue. We need a link to a public GitHub repository or a link to the SWC playground.

The bug template that you filled out has a section called "Link to the code that reproduces this issue", which is where you should provide the link to the reproduction.

What should I do?

Depending on the reason the issue was closed, you can do the following:

In general, assume that we should not go through a lengthy onboarding process at your company code only to be able to verify an issue.

My repository is private and cannot make it public

In most cases, a private repo will not be a sufficient minimal reproduction, as this codebase might contain a lot of unrelated parts that would make our investigation take longer. Please do not make it public. Instead, create a new repository using the templates above, adding the relevant code to reproduce the issue. Common things to look out for:

I did not open this issue, but it is relevant to me, what can I do to help?

Anyone experiencing the same issue is welcome to provide a minimal reproduction following the above steps by opening a new issue.

I think my reproduction is good enough, why aren't you looking into it quickly?

We look into every SWC issue and constantly monitor open issues for new comments.

However, sometimes we might miss one or two due to the popularity/high traffic of the repository. We apologize, and kindly ask you to refrain from tagging core maintainers, as that will usually not result in increased priority.

Upvoting issues to show your interest will help us prioritize and address them as quickly as possible. That said, every issue is important to us, and if an issue gets closed by accident, we encourage you to open a new one linking to the old issue and we will look into it.

kdy1 commented 2 weeks ago

https://rustdoc.swc.rs/swc_core/ecma/utils/swc_ecma_ast/struct.Ident.html