Fixed nil RHS bug in alternative operator #838

This commit is contained in:
Mike Farah 2021-05-28 16:59:02 +10:00
parent 38b9856f50
commit f1f75683c1
4 changed files with 27 additions and 2 deletions

View File

@ -5,6 +5,12 @@ import (
)
var alternativeOperatorScenarios = []expressionScenario{
{
skipDoc: true,
expression: `.b // .c`,
document: `a: bridge`,
expected: []string{},
},
{
skipDoc: true,
expression: `(.b // "hello") as $x`,

View File

@ -12,6 +12,14 @@ var booleanOperatorScenarios = []expressionScenario{
"D0, P[], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "b: hi",
expression: `.a or .c`,
expected: []string{
"D0, P[], (!!bool)::false\n",
},
},
{
skipDoc: true,
document: "b: hi",

View File

@ -5,6 +5,13 @@ import (
)
var equalsOperatorScenarios = []expressionScenario{
{
skipDoc: true,
expression: ".a == .b",
expected: []string{
"D0, P[], (!!bool)::true\n",
},
},
{
skipDoc: true,
document: "cat",

View File

@ -31,7 +31,9 @@ func resultsForRhs(d *dataTreeNavigator, context Context, lhsCandidate *Candidat
if err != nil {
return err
}
results.PushBack(resultCandidate)
if resultCandidate != nil {
results.PushBack(resultCandidate)
}
return nil
}
@ -42,7 +44,9 @@ func resultsForRhs(d *dataTreeNavigator, context Context, lhsCandidate *Candidat
if err != nil {
return err
}
results.PushBack(resultCandidate)
if resultCandidate != nil {
results.PushBack(resultCandidate)
}
}
return nil
}