pacc 8.1.7 → 8.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/ast.mjs +8 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pacc",
3
- "version": "8.1.7",
3
+ "version": "8.1.8",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "provenance": true
package/src/ast.mjs CHANGED
@@ -77,6 +77,7 @@ export function binopEval(node, current, context) {
77
77
 
78
78
  export function pathEval(node, current, context) {
79
79
  let collection = false;
80
+ let first = true;
80
81
  for (const item of node.path) {
81
82
  switch (typeof item) {
82
83
  case "string":
@@ -90,8 +91,11 @@ export function pathEval(node, current, context) {
90
91
  current = current.map(x => x[item]);
91
92
  } else {
92
93
  current =
93
- (current instanceof Map ? current.get(item) : current[item]) ??
94
- context.getGlobal(item);
94
+ (current instanceof Map ? current.get(item) : current[item]);
95
+
96
+ if(first && current === undefined) {
97
+ current = context.getGlobal(item);
98
+ }
95
99
  }
96
100
  }
97
101
  break;
@@ -103,6 +107,8 @@ export function pathEval(node, current, context) {
103
107
  current = current.filter(c => item.eval(item, c, context));
104
108
  collection = true;
105
109
  }
110
+
111
+ first = false;
106
112
  }
107
113
 
108
114
  return current;