lemmascript 0.6.12 → 0.6.14

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.
@@ -179,9 +179,14 @@ class Parser {
179
179
  }
180
180
  if (t?.type === "op" && ["===", "!==", "==", "!=", ">=", "<=", ">", "<"].includes(t.value)) {
181
181
  this.advance();
182
- // Normalize == to ===, != to !== so downstream sees one spelling
183
- const op = t.value === "==" ? "===" : t.value === "!=" ? "!==" : t.value;
184
- return { kind: "binop", op, left, right: this.parseAdd() };
182
+ const right = this.parseAdd();
183
+ const isNullishAtom = (x) => x.kind === "var" && (x.name === "null" || x.name === "undefined");
184
+ // Keep loose `==` / `!=` distinct when comparing against `null`/`undefined`
185
+ // so `//@ ensures x == null` checks both sentinels on `Nullish<T>` (#304),
186
+ // while non-nullish spec equalities (`a == b`) continue normalizing to `===`.
187
+ const keepLoose = (t.value === "==" || t.value === "!=") && (isNullishAtom(left) || isNullishAtom(right));
188
+ const op = keepLoose ? t.value : t.value === "==" ? "===" : t.value === "!=" ? "!==" : t.value;
189
+ return { kind: "binop", op, left, right };
185
190
  }
186
191
  return left;
187
192
  }
@@ -268,11 +273,10 @@ class Parser {
268
273
  this.advance();
269
274
  return { kind: "bool", value: false };
270
275
  }
271
- // Match the body extractor (extract.ts NullLiteral): `null` and
272
- // `undefined` are interchangeable in LS, both map to None.
276
+ // Preserve `null` distinctly from `undefined` (#304).
273
277
  if (t.value === "null") {
274
278
  this.advance();
275
- return { kind: "var", name: "undefined" };
279
+ return { kind: "var", name: "null" };
276
280
  }
277
281
  // new Set<T>() / new Map<K,V>()
278
282
  if (t.value === "new") {