Skip to content

Commit

Permalink
clear flags
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed Nov 21, 2024
1 parent 4038f65 commit b3a05fa
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -891,9 +891,13 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
let kind = AstKind::AssignmentExpression(self.alloc(expr));
self.enter_node(kind);

// Only when the operator is not an `=` operator, the left-hand side is both read and write.
// <https://tc39.es/ecma262/#sec-assignment-operators-runtime-semantics-evaluation>
if !expr.operator.is_assign() {
if expr.operator.is_assign() {
// Clear the current reference flags in case the left-hand side is both read and write.
self.current_reference_flags = ReferenceFlags::empty();
} else {
// Only when the operator is not an `=` operator, the left-hand side is both read and write.
// The write flags will be set in the `visit_assignment_target` method.
// <https://tc39.es/ecma262/#sec-assignment-operators-runtime-semantics-evaluation>
self.current_reference_flags = ReferenceFlags::Read;
}

Expand Down Expand Up @@ -1835,7 +1839,7 @@ impl<'a> Visit<'a> for SemanticBuilder<'a> {
) {
// NOTE: AstKind doesn't exists!
let prev_reference_flags = self.current_reference_flags;
self.current_reference_flags |= ReferenceFlags::Write;
self.current_reference_flags = ReferenceFlags::Write;
self.visit_identifier_reference(&it.binding);
self.current_reference_flags = prev_reference_flags;
if let Some(init) = &it.init {
Expand Down

0 comments on commit b3a05fa

Please sign in to comment.