-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
'let' statements before using statements are now properly converted into 'var' statements #14260
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Several test failures
continue; | ||
if (p.const_values.contains(decl.binding.data.b_identifier.ref)) { | ||
any_decl_in_const_values = true; | ||
const symbol = p.symbols.items[decl.binding.data.b_identifier.ref.innerIndex()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const symbol = p.symbols.items[decl.binding.data.b_identifier.ref.innerIndex()]; | |
const symbol = &p.symbols.items[decl.binding.data.b_identifier.ref.innerIndex()]; |
src/js_parser.zig
Outdated
} | ||
} | ||
decls[end] = decl; | ||
end += 1; | ||
} | ||
local.decls.len = @as(u32, @truncate(end)); | ||
if (end == 0) { | ||
stmt.* = stmt.*.toEmpty(); | ||
if (any_decl_in_const_values) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this if be there? i'm confused
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's the only side effect that happens if it being const/in const_values is true. so we don't want it to happen if the check is false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(the locals.decls.len assignment is a no-op if it's false because end will be the len value. it should probably be moved into the if statement too though then)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge conflict
fixed |
What does this PR do?
fixes #12407 and the regression demonstrated in #11083 where a
let
statement before ausing
would not be converted into avar
so anything referencing it outside of the generated try/catch would raise aReferenceError
How did you verify your code works?