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

loop varible is undefined in inline anonymous function in template #8378

Closed
xiangnanscu opened this issue May 20, 2023 · 2 comments
Closed

Comments

@xiangnanscu
Copy link

Vue version

latest

Link to minimal reproduction

https://play.vuejs.org/#eNqFUcFOwzAM/RUrl7bS1gqOoxsDCRDiAAc4LTuUkqKKNIkaDyFV+XecZmXdijQpBz/7xX5+7tiNMen3TrAFy1E0RhYoVlwB5LWStRJzFBY9BkDxg0vObt8eOAuZtRVSlDivaikslUIWIO6gT4FLYLmCbsgDVLqFuNTKYs8AXQVmMiYBSP0ZR0URzfrqdaqKRiRXB4Ybwn0QRme98GPpg+rnJ84megO894gz/zvPRh7ktmxrg2AF7gzhujG6RXjsm7/63lWrG5qdZoec9zKo4SrsSbvAEnyspUgJDYXRdCL859lZt0ZdY86KgrOpY2QRvTwL29AebMaO9U5v/75D1ArWpazLLzJKNDXG0UgwXWavdwGbDvy0BVyAmw3xJbgtrcLZqutMq41N/SGcy7PQ+9Tsqd1h7/4v2fMhKlL84lG8iXyvaJsMJC/vj3NHgDgn1916M8YmuF91Vv1F

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

@sphinxrave
Copy link

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

@edison1105
Copy link
Member

duplicate of #7238

@github-actions github-actions bot locked and limited conversation to collaborators Sep 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants