Skip to content

Commit 2824d66

Browse files
committed
Multiply uses a readonly context #2558
1 parent 4bbffa9 commit 2824d66

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

pkg/yqlib/operator_multiply.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func multiplyAssignOperator(d *dataTreeNavigator, context Context, expressionNod
3030

3131
func multiplyOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) {
3232
log.Debugf("MultiplyOperator")
33-
return crossFunction(d, context, expressionNode, multiply(expressionNode.Operation.Preferences.(multiplyPreferences)), false)
33+
return crossFunction(d, context.ReadOnlyClone(), expressionNode, multiply(expressionNode.Operation.Preferences.(multiplyPreferences)), false)
3434
}
3535

3636
func getComments(lhs *CandidateNode, rhs *CandidateNode) (leadingContent string, headComment string, footComment string) {

pkg/yqlib/operator_multiply_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ var mergeWithGlobB = `
9696
`
9797

9898
var multiplyOperatorScenarios = []expressionScenario{
99+
{
100+
description: "multiple should be readonly",
101+
skipDoc: true,
102+
document: "",
103+
expression: ".x |= (root | (.a * .b))",
104+
expected: []string{
105+
"D0, P[], ()::x: null\n",
106+
},
107+
},
99108
{
100109
description: "glob keys are treated as literals when merging",
101110
skipDoc: true,

0 commit comments

Comments
 (0)