Multiply uses a readonly context #2558

This commit is contained in:
Mike Farah 2026-01-31 16:47:58 +11:00
parent 4bbffa9022
commit 2824d66a65
2 changed files with 10 additions and 1 deletions

View File

@ -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) {

View File

@ -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,