-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
fix(compiler-core): fix the variable prefix problem in the inline expression #11467
Conversation
Size ReportBundles
Usages
|
try catch
I found a couple of things while testing this, though I suspect they might be considered out of scope for this specific fix. The variable for try {
throw new Error('blah')
} catch ({ message, stack }) {
console.log(message)
console.log(stack)
} The MDN entry for This doesn't seem to work with the fix proposed here, though judging by the error message it seems that it's failing much earlier in the parsing process. The other thing I noticed is that the variable doesn't seem to be scoped correctly. It should just be scoped to the block, but it leaks out. It looks like this isn't just a problem with try {
// ...
} catch (err) {
console.log(err)
}
// This `err` should come from the surrounding scope, it is not the same as the `err` inside `catch`.
console.log(err) for (const msg of msgs) {
console.log(msg)
}
// This shouldn't be the same `msg` that was inside the loop, as it used `const`.
// If the loop had used `var` it would be the same.
console.log(msg) |
Indeed, there are still a lot of problems here. |
try catch
I've just retested this. It seems that the It looks like the problem has been fixed for It seems that destructuring on the I wonder whether this should be handled recursively, maybe by calling |
thanks for your suggestions |
Thanks for the PR, but the change seems unnecessarily complex - we just need to handle I partially reused the test you created in this PR.
|
… expression transforms ref #11467 (comment)
For loop leak should not happen if the declaration is using |
In normal JavaScript the code is invalid and results in an error (accessing an in-scope const before initialization), Vue should not change that. |
close #11465
this pr playground