Skip to content

Commit 7f3adf6

Browse files
andrew-colemanmattbaileyuk
authored andcommitted
unary negation of undefined (no match) should return undefined
1 parent 557249e commit 7f3adf6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

jsonata.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1817,7 +1817,9 @@ var jsonata = (function() {
18171817
switch (expr.value) {
18181818
case '-':
18191819
result = yield * evaluate(expr.expression, input, environment);
1820-
if (isNumeric(result)) {
1820+
if(typeof result === 'undefined') {
1821+
result = undefined;
1822+
} else if (isNumeric(result)) {
18211823
result = -result;
18221824
} else {
18231825
throw {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"expr": "- notexist",
3+
"dataset": "dataset0",
4+
"bindings": {},
5+
"undefinedResult": true
6+
}

0 commit comments

Comments
 (0)