@vue/compiler-sfc can't compile this code correct #12790
Labels
🔨 p3-minor-bug
Priority 3: this fixes a bug, but is an edge case that only affects very specific usage.
scope: sfc
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
value
)value
),console.log(value)
value
),and function body insert an emptytry-catch
like demo.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
core/packages/compiler-sfc/src/script/definePropsDestructure.ts
Line 255 in 7ecd2a2
and
core/packages/compiler-sfc/src/script/definePropsDestructure.ts
Line 131 in 7ecd2a2
when walk into function. And
currentScope.value
is not revert totrue
.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
The text was updated successfully, but these errors were encountered: