Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ fn is_read(current_node_id: NodeId, semantic: &Semantic) -> bool {
return true;
}
}
(AstKind::PrivateFieldExpression(_), AstKind::LogicalExpression(logical_expr)) => {
// Reading the left side of a logical expression can affect control flow
// (e.g. `this.#flag && sideEffect()`), even when used as a statement.
if logical_expr.left.span().contains_inclusive(curr.span()) {
return true;
}
}
_ => {
return false;
}
Expand Down Expand Up @@ -495,6 +502,7 @@ fn test() {
r"class Foo { #x; method(val) { switch(val) { case (a ? this.#x : b): break; } } }",
r"class Foo { #x; method() { throw a ? this.#x : new Error(); } }",
r"class Foo { #x; method() { while (a ? this.#x : b) {} } }",
r"class Bug { #flag = false; foo() { this.#flag && console.log('spam'); } }",
r"class Foo { #a; #b; #c; method() { return this.#a ? this.#b : this.#c; } }",
// Issue #15548: Private member used in logical expression on RHS of assignment
r"class ExampleFoo { #foo = 0; foo(foo) { foo = foo ?? this.#foo; return foo; } }",
Expand Down
Loading