diff --git a/pkg/yqlib/operator_multiply.go b/pkg/yqlib/operator_multiply.go index 8ea69a18..b32ee345 100644 --- a/pkg/yqlib/operator_multiply.go +++ b/pkg/yqlib/operator_multiply.go @@ -30,7 +30,7 @@ func multiplyAssignOperator(d *dataTreeNavigator, context Context, expressionNod func multiplyOperator(d *dataTreeNavigator, context Context, expressionNode *ExpressionNode) (Context, error) { log.Debugf("MultiplyOperator") - return crossFunction(d, context, expressionNode, multiply(expressionNode.Operation.Preferences.(multiplyPreferences)), false) + return crossFunction(d, context.ReadOnlyClone(), expressionNode, multiply(expressionNode.Operation.Preferences.(multiplyPreferences)), false) } func getComments(lhs *CandidateNode, rhs *CandidateNode) (leadingContent string, headComment string, footComment string) { diff --git a/pkg/yqlib/operator_multiply_test.go b/pkg/yqlib/operator_multiply_test.go index 1c7eca32..7efeb524 100644 --- a/pkg/yqlib/operator_multiply_test.go +++ b/pkg/yqlib/operator_multiply_test.go @@ -96,6 +96,15 @@ var mergeWithGlobB = ` ` var multiplyOperatorScenarios = []expressionScenario{ + { + description: "multiple should be readonly", + skipDoc: true, + document: "", + expression: ".x |= (root | (.a * .b))", + expected: []string{ + "D0, P[], ()::x: null\n", + }, + }, { description: "glob keys are treated as literals when merging", skipDoc: true,