Skip to content

@vue/compiler-sfc can't compile this code correct #12790

Open
@windsonR

Description

@windsonR

Vue version

3.5.13

Link to minimal reproduction

https://play.vuejs.org/#eNp9UU1PAyEQ/SuEU5s022j1UtcmanrQgzbqkcRs6OxHZYHAsK7Z7H932LUfh6ZAyPDeY3gzdPzB2qQJwJc89dJVFpkHDHYltDTaI+tYk6kArGf3bAt5pWHjjPWT6Z3Q44w6oyBRppgM2qnQedASK6NZDP5R1gmN7pf2XmYoyxgM61yCdD66IR90QKityhDolJbXqzyd0x5FJwSfcfSUKq+KZOeNporoBcYEl6a2lQL3ZqMlL/gyWmE0BM+UMj8vA4YuwGyPyxLk9xl859uICb5x4ME1IPiBw8wVgCO9/niFluIDWZttUKS+QL4DtSFEj6PsMegt2T7RDW6fa2scVrr49OsWQft9UdFoVPaDXnD61qcLpR/tLpKb4R79BnXxqwEXc1IDF8ltcrXg/R/LWbpE

Steps to reproduce

  1. define a prop with any name(Ex: value)
  2. input any code, to use the prop(Ex: value),console.log(value)
  3. before the prop use, input a function.It's param use prop's name(Ex: value),and function body insert an empty try-catch like demo.
  4. will show error value is not defined.

What is expected?

Step 2 's code will compile into console.log(__props.value)

What is actually happening?

In @vue/compiler-sfc's code

walkFunctionParams(node, registerLocalBinding)

and

when walk into function. And currentScope.value is not revert to true.cause this error!

In my opinion, this is a rather serious problem.
For example:
After the first use of props(value), and before the second use of it, if there is a function whose parameter is the name of this prop(value), then it will cause all subsequent properties to not function properly, leading to many issues.

System Info

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.scope: sfc

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions