Skip to content

Commit

Permalink
fix(semantic) incorrect reference flag caused by MemberExpression (#3354
Browse files Browse the repository at this point in the history
  • Loading branch information
Dunqing committed May 19, 2024
1 parent 89a1f97 commit 8a30a98
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/oxc_semantic/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1998,6 +1998,7 @@ impl<'a> SemanticBuilder<'a> {
self.current_reference_flag -= ReferenceFlag::Read;
}
}
AstKind::MemberExpression(_) => self.current_reference_flag = ReferenceFlag::empty(),
AstKind::AssignmentTarget(_) => self.current_reference_flag -= ReferenceFlag::Write,
_ => {}
}
Expand Down
1 change: 1 addition & 0 deletions crates/oxc_semantic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ mod tests {
"let a; let b; let c; a[c[b = c['a']] = 'c'] = 'b'",
ReferenceFlag::read(),
),
(SourceType::default(), "console.log;let a=0;a++", ReferenceFlag::write()),
// typescript
(typescript, "let a: number = 1; (a as any) = true", ReferenceFlag::write()),
(typescript, "let a: number = 1; a = true as any", ReferenceFlag::write()),
Expand Down

0 comments on commit 8a30a98

Please sign in to comment.