Fixed string, null concact consistency #1712

This commit is contained in:
Mike Farah 2023-08-30 09:46:45 +10:00
parent 71f95ab87b
commit 55c0d485ba
2 changed files with 19 additions and 1 deletions

View File

@ -107,7 +107,11 @@ func addScalars(context Context, target *CandidateNode, lhs *yaml.Node, rhs *yam
} else if lhsTag == "!!str" {
target.Node.Tag = lhs.Tag
target.Node.Value = lhs.Value + rhs.Value
if rhsTag == "!!null" {
target.Node.Value = lhs.Value
} else {
target.Node.Value = lhs.Value + rhs.Value
}
} else if rhsTag == "!!str" {
target.Node.Tag = rhs.Tag
target.Node.Value = lhs.Value + rhs.Value

View File

@ -225,6 +225,20 @@ var addOperatorScenarios = []expressionScenario{
"D0, P[], (!cool)::3cat\n",
},
},
{
skipDoc: true,
expression: `null + "cat"`,
expected: []string{
"D0, P[], (!!str)::cat\n",
},
},
{
skipDoc: true,
expression: `"cat" + null`,
expected: []string{
"D0, P[], (!!str)::cat\n",
},
},
{
description: "Number addition - float",
subdescription: "If the lhs or rhs are floats then the expression will be calculated with floats.",