Fixed alternative operator

This commit is contained in:
Mike Farah 2021-06-10 09:35:07 +10:00
parent 09c5ed24be
commit d1548ead71
2 changed files with 11 additions and 0 deletions

View File

@ -9,6 +9,9 @@ func alternativeFunc(d *dataTreeNavigator, context Context, lhs *CandidateNode,
if lhs == nil {
return rhs, nil
}
if rhs == nil {
return lhs, nil
}
lhs.Node = unwrapDoc(lhs.Node)
rhs.Node = unwrapDoc(rhs.Node)
log.Debugf("Alternative LHS: %v", lhs.Node.Tag)

View File

@ -19,6 +19,14 @@ var alternativeOperatorScenarios = []expressionScenario{
"D0, P[], (doc)::a: bridge\n",
},
},
{
skipDoc: true,
expression: `.a // .b`,
document: `a: 2`,
expected: []string{
"D0, P[a], (!!int)::2\n",
},
},
{
description: "LHS is defined",
expression: `.a // "hello"`,