From 52851c93bb598c290deaf1cdf3422c0c37f45fc0 Mon Sep 17 00:00:00 2001 From: Thomas Neidhart Date: Mon, 23 Sep 2024 08:51:30 +0200 Subject: [PATCH] fix: chain operator should respect array constructor --- src/parser.js | 1 + test/test-suite/groups/hof-map/case0010.json | 6 ++++++ test/test-suite/groups/hof-map/case0011.json | 6 ++++++ 3 files changed, 13 insertions(+) create mode 100644 test/test-suite/groups/hof-map/case0010.json create mode 100644 test/test-suite/groups/hof-map/case0011.json diff --git a/src/parser.js b/src/parser.js index 629ff82c..9cffaf3d 100644 --- a/src/parser.js +++ b/src/parser.js @@ -1194,6 +1194,7 @@ const parser = (() => { result = {type: 'apply', value: expr.value, position: expr.position}; result.lhs = processAST(expr.lhs); result.rhs = processAST(expr.rhs); + result.keepArray = result.lhs.keepArray || result.rhs.keepArray; break; default: result = {type: expr.type, value: expr.value, position: expr.position}; diff --git a/test/test-suite/groups/hof-map/case0010.json b/test/test-suite/groups/hof-map/case0010.json new file mode 100644 index 00000000..8f408c52 --- /dev/null +++ b/test/test-suite/groups/hof-map/case0010.json @@ -0,0 +1,6 @@ +{ + "expr": "( $square := function($x){$x*$x}; $map([1], $square)[] )", + "data": null, + "bindings": {}, + "result": [1] +} diff --git a/test/test-suite/groups/hof-map/case0011.json b/test/test-suite/groups/hof-map/case0011.json new file mode 100644 index 00000000..2bd7fa3e --- /dev/null +++ b/test/test-suite/groups/hof-map/case0011.json @@ -0,0 +1,6 @@ +{ + "expr": "( $data := [1]; $square := function($x){$x*$x}; $data ~> $map($square)[] )", + "data": null, + "bindings": {}, + "result": [1] +}