mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:44:27 +00:00
[vm/aot/tfa] Fix handling of 'assert' statement
With conditional data flow TFA should model control flow in 'assert' statements more precisely: message expression is not always executed; variable values and condition should not be propagated down from message expression. TEST=language/assert/message_test Fixes https://github.com/dart-lang/sdk/issues/52503 Change-Id: Iea3b0bae38ab328bd1ad92cacc6b4c3c99f9753f Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/305342 Commit-Queue: Alexander Markov <alexmarkov@google.com> Reviewed-by: Slava Egorov <vegorov@google.com>
This commit is contained in:
parent
284296f862
commit
8b8d063679
1 changed files with 8 additions and 1 deletions
|
@ -2146,11 +2146,18 @@ class SummaryCollector extends RecursiveResultVisitor<TypeExpr?> {
|
|||
@override
|
||||
TypeExpr? visitAssertStatement(AssertStatement node) {
|
||||
if (!kRemoveAsserts) {
|
||||
_addUse(_visit(node.condition));
|
||||
final trueState = _cloneVariableValues(_variableValues);
|
||||
final falseState = _cloneVariableValues(_variableValues);
|
||||
_visitCondition(node.condition, trueState, falseState);
|
||||
|
||||
final message = node.message;
|
||||
if (message != null) {
|
||||
final savedCondition = _currentCondition;
|
||||
_variableValues = falseState;
|
||||
_visit(message);
|
||||
_currentCondition = savedCondition;
|
||||
}
|
||||
_variableValues = trueState;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue