Skip to content

Commit

Permalink
[flow] Do not call this#optional for invalid void_test
Browse files Browse the repository at this point in the history
Summary:
For invalid `void_test` (e.g. `foo === undefined` where undefined is defined locally), we shouldn't call optional_chaining because it will add refinement to `obj` in `obj.foo === undefined`, while in this case there shouldn't be any refinements.

Changelog: [internal]

Reviewed By: jbrown215

Differential Revision: D66019564

fbshipit-source-id: 67ea8f172e1f4de49ec340c2e1954dad9fad21bb
  • Loading branch information
SamChou19815 authored and facebook-github-bot committed Nov 18, 2024
1 parent b47b131 commit 6a15820
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/analysis/env_builder/name_resolver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4951,7 +4951,7 @@ module Make (Context : C) (FlowAPIUtils : F with type cx = Context.t) :
this#commit_refinement refis;
if will_negate then this#negate_new_refinements ()
end else begin
ignore @@ this#optional_chain expr;
ignore @@ this#expression expr;
this#commit_refinement refis
end

Expand Down

0 comments on commit 6a15820

Please sign in to comment.