loop varible is undefined in inline anonymous function in template
Vue version
latest
Link to minimal reproduction
Steps to reproduce
Click BUG
, you will see console output:
aa undefined
What is expected?
output should be:
aa 1
aa 2
What is actually happening?
aa undefined
System Info
No response
Any additional comments?
No response
It was compiled to ...
_createVNode(__import_1__.default, {
text: "BUG",
onSelectFiles: _cache[0] || (_cache[0] =
(a) => {
for (const file of a.files) {
_unref(log)('aa', _ctx.file.name);
}
}
)//...
renaming file to other variables does not change behavior. Vue probably didn't pick up that this is a local variable and instead assumes all vars are on _ctx
duplicate of https://github.com/vuejs/core/issues/7238