Skip to content

Commit

Permalink
Added new method on IExternalRule to help with invariantexpression ch… (
Browse files Browse the repository at this point in the history
#2725)

On an effort to remove null rule binding, we need the ability to have an
option to apply null binding before doing the check if binding is null.
This change adds a new method on IExternalRule to help with that.
  • Loading branch information
Shpakh-MSFT authored Nov 1, 2024
1 parent a1560ea commit e1e5381
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,8 @@ internal interface IExternalRule

// Returns true when Binding is non-null, otherwise false.
bool HasValidBinding { get; }

// Returns true when rule is constant.
bool IsInvariantExpression { get; }
}
}
4 changes: 1 addition & 3 deletions src/libraries/Microsoft.PowerFx.Core/Binding/Binder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3619,9 +3619,7 @@ public override void PostVisit(DottedNameNode node)
// we need to mark the node as constant, and save the control info so we may look up the
// rule later.
if (controlInfo?.GetRule(property.InvariantName) is IExternalRule rule &&
rule.HasValidBinding &&
!rule.HasErrorsOrWarnings &&
rule.Binding.IsConstant(rule.Binding.Top))
rule.IsInvariantExpression)
{
value = controlInfo;
isConstant = true;
Expand Down

0 comments on commit e1e5381

Please sign in to comment.