Skip to content

feat(M6a): semantic-cluster fixes ($$ root, $keys/$spread, undefined arithmetic, object keys)#18

Merged
flearc merged 6 commits into
mainfrom
feature/m6a-semantics
Jun 24, 2026
Merged

feat(M6a): semantic-cluster fixes ($$ root, $keys/$spread, undefined arithmetic, object keys)#18
flearc merged 6 commits into
mainfrom
feature/m6a-semantics

Conversation

@flearc

@flearc flearc commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

M6a fixes four independent semantic divergences that all teach the same jsonata invariant — an empty sequence IS undefined, and undefined propagates by omission, not by empty-string/empty-array. It's the first of the M6 "structural polish" split (M6b = parser [] keepArray; #$var later).

  • C-1 $$ root context — bind the input under the name "$" at the top frame, so $$ resolves through the normal variable chain from any nested scope (it was never bound → all $$ forms returned undefined). $ (current context) is unaffected.
  • B-3 $keys/$spread$keys of an empty result is now undefined (not []); $spread echoes a scalar argument and an empty $spread is undefined.
  • C-4a undefined arithmeticx + undefined → undefined (and unary -undefined → undefined), matching jsonata's exact operand ordering: both defined-non-number type errors (T2001/T2002) fire before the undefined short-circuit; unary - on a non-number raises D1002.
  • C-3 object-literal key rules — an undefined key skips the pair, a non-string key raises T1003, an undefined value omits the pair, and a duplicate key raises D1009 (detected at key-time, independent of value).

Results

  • Official jsonata suite: 1153 → 1174 / 1682 (+21, 69.0% → 69.8%), zero regressions. Gains across conditionals, function-keys, numeric-operators, object-constructor, function-spread, and 5 more groups.
  • 448/448 unit tests green.

Verification

An adversarial fidelity review against a jsonata-js v2.2.1 oracle (~100 probes) found three suite-invisible in-scope divergences — $spread({}), duplicate-key-with-undefined-value, and unary-minus error code — all fixed in 204ab63. (The official suite runner accepts any structured error without comparing codes, so error-code fidelity is checked only by the oracle.)

Deferred (out of scope): singleton-unwrap of builtin collection results ($keys({a:1})["a"] vs jsonata "a") — an architectural sequence-semantics concern for a dedicated later milestone.

Test Plan

  • busted full unit suite — 448/448
  • scripts/run-suite.sh — 1174/1682, zero regressions
  • Adversarial fidelity review vs jsonata-js v2.2.1 oracle

🤖 Generated with Claude Code

flearc and others added 6 commits June 24, 2026 11:17
1153 → 1174 (+21) out of 1682 total.

Newly-passing groups:
  conditionals        +4  (case000/001/003/004)
  function-keys       +4  (case002/004/005/006)
  function-spread     +2  (case000/003)
  function-lookup     +1  (case003)
  missing-paths       +1  (case004)
  numeric-operators   +3  (case012/013/016)
  object-constructor  +3  (case014/023/024)
  performance         +1  (case000)
  simple-array-selectors +1 (case014)
  wildcards           +1  (case008)

Zero regressions. Guard + 448 unit tests green.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@flearc flearc merged commit 77742f5 into main Jun 24, 2026
1 check passed
@flearc flearc deleted the feature/m6a-semantics branch June 24, 2026 03:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant