Refining add op

This commit is contained in:
Mike Farah
2025-06-12 15:41:27 +10:00
parent fd7e750040
commit 176873e93a
4 changed files with 93 additions and 3 deletions
+3 -3
View File
@@ -38,9 +38,9 @@ func toNodes(candidate *CandidateNode, lhs *CandidateNode) []*CandidateNode {
func addOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
log.Debugf("Add operator")
// if we don't have any matching nodes, but we were piped into (have a parent exp?) then we
// shouldn't calcWhenEmpt
calcWhenEmpty := expressionNode.Parent == nil
// only calculate when empty IF we are the root expression; OR
// calcWhenEmpty := expressionNode.Parent == nil || expressionNode.Parent.LHS == expressionNode
calcWhenEmpty := context.MatchingNodes.Len() > 0
return crossFunction(d, context.ReadOnlyClone(), expressionNode, add, calcWhenEmpty)
}