From 6977ef24edb75cc228f5e7e9304e6d66ae9729a7 Mon Sep 17 00:00:00 2001 From: Springcomp Date: Tue, 7 Mar 2023 17:33:23 +0100 Subject: [PATCH] [jep-19] Pipe evaluation --- src/TreeInterpreter.ts | 5 +---- test/compliance/pipe.json | 4 ++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/TreeInterpreter.ts b/src/TreeInterpreter.ts index adc0bfb..923efd6 100644 --- a/src/TreeInterpreter.ts +++ b/src/TreeInterpreter.ts @@ -52,10 +52,10 @@ export class TreeInterpreter { case 'Subexpression': result = this.visit((node as ExpressionNode).children[0], value); for (i = 1; i < (node as ExpressionNode).children.length; i += 1) { - result = this.visit((node as ExpressionNode).children[1], result); if (result === null) { return null; } + result = this.visit((node as ExpressionNode).children[1], result); } return result; case 'IndexExpression': @@ -184,9 +184,6 @@ export class TreeInterpreter { case 'Identity': return value; case 'MultiSelectList': - if (value === null) { - return null; - } collected = []; for (i = 0; i < (node as ExpressionNode).children.length; i += 1) { collected.push(this.visit((node as ExpressionNode).children[i], value)); diff --git a/test/compliance/pipe.json b/test/compliance/pipe.json index b10c0a4..3f1f15d 100644 --- a/test/compliance/pipe.json +++ b/test/compliance/pipe.json @@ -126,6 +126,10 @@ { "expression": "foo[*].bar[*] | [0][0]", "result": {"baz": "one"} + }, + { + "expression": "`null`|[@]", + "result": [ null ] } ] }]