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

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

Open
windsonR opened this issue Jan 30, 2025 · 0 comments · May be fixed by #12792
Open

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

windsonR opened this issue Jan 30, 2025 · 0 comments · May be fixed by #12792
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: sfc

Comments

@windsonR
Copy link

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

@edison1105 edison1105 added scope: sfc 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: sfc
Projects
None yet
2 participants