@mark1russell7/vex-compiler 0.13.2 → 0.13.4

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.
@@ -145,8 +145,12 @@ function baseOf(axis: Axis): Axis {
145
145
  * - in a tree in post-order, at the key of a target of the axis `children` of the key.
146
146
  *
147
147
  * A read in the body of a function can evaluate at each place of a call, so it is not one of these forms.
148
+ *
149
+ * The columns of `fused` come before `self` in one loop over the keys (COMPILE.MODULE.ONCE). The loop evaluates each of
150
+ * them at a key before `self` at that key. Thus a read of one of them reads a finished cell only at the key itself, or
151
+ * in one of the three forms.
148
152
  */
149
- export function readsFinished(columns: ReadonlyMap<string, Expr>, order: readonly string[], self: string, tree: boolean): boolean {
153
+ export function readsFinished(columns: ReadonlyMap<string, Expr>, order: readonly string[], self: string, tree: boolean, fused: ReadonlySet<string> = new Set()): boolean {
150
154
  const formula = columns.get(self);
151
155
  if (formula === undefined || shapeError(formula) !== undefined) return false;
152
156
  const { reverse, post } = keyOrderOf(readsOf(columns, new Map(), self).directions);
@@ -166,12 +170,15 @@ export function readsFinished(columns: ReadonlyMap<string, Expr>, order: readonl
166
170
  const { column, at } = e.data;
167
171
  const index = order.indexOf(column);
168
172
  if (index > position) return false;
169
- if (column !== self) continue;
173
+ if (column !== self && !fused.has(column)) continue;
170
174
  const [move, ...rest] = at;
175
+ // The cell of a fused column at the key itself is finished. The cell of `self` at the key is a cycle.
176
+ const here = column !== self && place === "key" && at.every((m) => m.t === "origin");
171
177
  const ok =
172
- place === "key"
178
+ here ||
179
+ (place === "key"
173
180
  ? move !== undefined && rest.length === 0 && ((tree && !post && move.t === "parent") || (!tree && !reverse && move.t === "offset" && move.d.length === 1 && (move.d[0] ?? 0) < 0))
174
- : place === "children" && tree && post && at.length === 0;
181
+ : place === "children" && tree && post && at.length === 0);
175
182
  if (!ok) return false;
176
183
  }
177
184
  }