[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:
Alexander Markov 2023-05-25 14:37:48 +00:00 committed by Commit Queue
parent 284296f862
commit 8b8d063679

View file

@ -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;
}