The component should execute without errors.
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.1
const { msg = 'HELLO!', input = ['NICE', 'EXCELLENT'] } = { };
for (const msg of input) {
console.log('NOT FAIL', msg);
}
console.log('NOT FAIL', { msg });
Vue version
3.5.26
Link to minimal reproduction
https://play.vuejs.org/#eNrNUlFv2jAQ/itXv5hKKKjrtgcWkBjKViYK1UDaJIwmFC40XWJHtsOQovz3nR0IbOv6OO0lyt333d3nu69io6II9iWyPgtNrNPCgkFbFkMh07xQ2kIFGhOoIdEqB05U3kJjlRfHfNBzgetEsJCxksZCbnYwcOUdfodZpuCL0tn2il8LGfaaaTSHAot5kW0sUgQQ+rZUOxDsokww6KeyKC2lV3wxv494F/h9tFiMPkZ8TXCPysPeRS/WZdaQlCTdBU9GSXpk5SYIFtOINEM9L2xKUgXrg0cctqGRPz75nNUldk/5+BHj78/kn8zB5QR70GhQ71GwFrMbvUPbwNFihgf6b8FcbcuM2C+An9GorHQaG9r7Um5J9gXPq534e6RytzTRwaI0p0c5oY5Ze75gdB+33b89/Sz3Nnjt64SsaYun2/7uEsg20p3JUhvnGGlRJ5sY4UGrwjR96ZB9MFaTuncu9jc8ZVZrytGQk2Oqo2f4XTSdzq/owp5OmRWfTcb+5NHXMYHRbMnXZMsBbDFJJfqJof8OO9fUVchEaejA2YoqOXa7bpQ5RGUYZGrXaY3UdVRX36pqKbP5Ej6MJlPiNDprx3vJyY83w+pIrcMeRb8Y9LjYm/92sxXU50X+ucfn1nixo3+5x2971M70tMbb4E3w6i2rfwJ+CZkN
Steps to reproduce
In the minimal reproduction example:
defineProps:const { msg = 'HELLO!', input = ['NICE', 'EXCELLENT'] } = defineProps<Props>();for...ofloop that reuses a destructured prop name:for (const msg of input) { console.log('MESSAGE', msg); }undefinedWhat is expected?
The component should execute without errors.
The
console.logstatement outside the loop should print without errors.What is actually happening?
The script fails with an
ReferenceError: msg is not definedat theconsole.logstatement that occurs after thefor...ofloop.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.vuein the example demonstrates how this works in javascript withoutdefineProps: