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
…eck.
  • Loading branch information
Shpakh-MSFT committed Oct 30, 2024
1 parent bc2b841 commit a690643
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.Adds valid null binding when addValidBindingIfNotPresent is true.
bool IsInvariantExpression(bool addValidBindingIfNotPresent);
}
}
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(addValidBindingIfNotPresent: true))
{
value = controlInfo;
isConstant = true;
Expand Down

0 comments on commit a690643

Please sign in to comment.