2ca7380ab0
Prior to this change, the first phase of flow analysis, in which flow analysis "looks ahead" to see which variables are potentially assigned in each code block, was failing to properly account for variables that are assigned by pattern assignment expressions. This "look ahead" information is used by flow analysis to determine the effects of nonlinear control flow (e.g. to figure out which variables to demote at the top of a loop, or to figure out which variables are potentially assigned inside a closure). As a result, it was possible to construct correct code that would be rejected by the analyzer and compiler, as well as incorrect code that would (unsoundly) be accepted. The fix is to call `AssignedVariables.write` from the analyzer's `FlowAnalysisVisitor`, and from the CFE's `BodyBuilder`, to let flow analysis know about variable assignments that occur inside pattern assignment expressions. Fixes #52745. Change-Id: I0e6f426a5c5c36f214d5a206aaf5a2de0bfdaac1 Bug: https://github.com/dart-lang/sdk/issues/52745 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/310502 Auto-Submit: Paul Berry <paulberry@google.com> Reviewed-by: Johnni Winther <johnniwinther@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>