-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Closed
Labels
🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.Priority 3: this fixes a bug, but is an edge case that only affects very specific usage.scope: sfc
Description
Vue version
3.5.26
Link to minimal reproduction
Steps to reproduce
In the minimal reproduction example:
- Destructure variables from
defineProps:const { msg = 'HELLO!', input = ['NICE', 'EXCELLENT'] } = defineProps<Props>(); - Declare a
for...ofloop that reuses a destructured prop name:for (const msg of input) { console.log('MESSAGE', msg); } - After the loop, the original variable from props is now
undefined
What is expected?
The component should execute without errors.
The console.log statement outside the loop should print without errors.
What is actually happening?
The script fails with an ReferenceError: msg is not defined at the console.log statement that occurs after the for...of loop.
System Info
System:
OS: Linux 6.18 openSUSE Tumbleweed 20260101
CPU: (24) x64 AMD Ryzen 9 9900X 12-Core Processor
Memory: 29.93 GB / 60.43 GB
Container: Yes
Shell: 5.3.9 - /bin/bash
Binaries:
Node: 22.14.0 - /home/phillip/.asdf/installs/nodejs/22.14.0/bin/node
Yarn: 1.22.22 - /home/phillip/.asdf/installs/nodejs/22.14.0/bin/yarn
npm: 10.9.2 - /home/phillip/.asdf/plugins/nodejs/shims/npm
Browsers:
Chromium: 143.0.7499.169
Firefox: 146.0.1
Firefox Developer Edition: 146.0.1Any additional comments?
Comp1.vue in the example demonstrates how this works in javascript without defineProps:
const { msg = 'HELLO!', input = ['NICE', 'EXCELLENT'] } = { };
for (const msg of input) {
console.log('NOT FAIL', msg);
}
console.log('NOT FAIL', { msg });
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.Priority 3: this fixes a bug, but is an edge case that only affects very specific usage.scope: sfc