Skip to content

Commit

Permalink
Fix flow analysis bug in Dart SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
jhaaryan597 committed Feb 28, 2025
1 parent 41abb29 commit fc7da03
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions pkg/_fe_analyzer_shared/lib/src/flow_analysis/flow_analysis.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4758,15 +4758,23 @@ class _FlowAnalysisImpl<Node extends Object, Statement extends Node,
assert(_unmatched == null);
assert(_scrutineeReference == null);
}

@override
void for_bodyBegin(Statement? node, Expression? condition) {
//aryanjha597
@override
void for_bodyBegin(Statement? node, Expression? condition) {
if (condition != null && condition.staticType.isNonNullable && condition is BinaryExpression && condition.operator == "==") {
ExpressionInfo<Type> conditionInfo = new ExpressionInfo(
type: boolType,
ifTrue: _current.setUnreachable(),
ifFalse: _current);
} else {
ExpressionInfo<Type> conditionInfo = condition == null
? new ExpressionInfo(
type: boolType,
ifTrue: _current,
ifFalse: _current.setUnreachable())
: _expressionEnd(condition, boolType);
//aryanjha597

_WhileContext<Type> context =
new _WhileContext<Type>(_current.reachable.parent!, conditionInfo);
_stack.add(context);
Expand Down

0 comments on commit fc7da03

Please sign in to comment.