Skip to content

feat(M6b): [] keepArray postfix + quoted-string step selector + trailing-; blocks#19

Merged
flearc merged 5 commits into
mainfrom
feature/m6b-keeparray
Jun 24, 2026
Merged

feat(M6b): [] keepArray postfix + quoted-string step selector + trailing-; blocks#19
flearc merged 5 commits into
mainfrom
feature/m6b-keeparray

Conversation

@flearc

@flearc flearc commented Jun 24, 2026

Copy link
Copy Markdown
Owner

Summary

M6b is the parser-syntax half of the M6 split — the [] keepArray postfix plus two isolated parser fixes.

  • [] keepArray — a trailing [] forces a path's final result to stay an array (suppresses the length-1 singleton unwrap). Faithful any-step rule: any step carrying [] (incl. a nested predicated sub-path) keeps the path's final result an array — e.g. Phone[type="mobile"][].number["077 7700 1234"] (the [] is on Phone, before .number). Implemented as a recursive path_keeps_array scan feeding the single path-branch finalize_sequence; every other finalize caller is untouched, so the singleton-unwrap default is byte-identical.
  • A-2: quoted-string path step → field selector — a string after . (and in first position) selects the named field (foo."bar"foo.bar), while a standalone/predicated string ("Red"[$$="Bus"]) stays a literal. Position-based, matching jsonata.
  • A-4: trailing ; in a block( a; b; ) is now tolerated.

Results

  • Official jsonata suite: 1174 → 1211 / 1682 (+37, 69.8% → 72.5%), zero regressions. Gains across flattening (+9, incl. the deferred case041 which passes for free), quoted-selectors, object-constructor, hof-map, transform, descendent-operator, and ~10 more groups.
  • 464/464 unit tests green.

Verification

Plan-grounding against the official cases caught a bug in the draft design (case037 disproved a "last-step" framing → corrected to the faithful any-step rule). An adversarial fidelity review vs the jsonata-js v2.2.1 oracle confirmed A-4 fully faithful, *[]/**[] match, and a 24-path regression sweep is clean; it found one A-2 gap (first-position quoted strings) fixed in ef953c3 (which unblocked 3 more cases).

Deferred/pre-existing (out of scope): the empty-array-vs-empty-object adapter ambiguity ($type([])"object", a from_lua JSON-input limitation); the obscure ("x").y parenthesized-literal-head edge.

Test Plan

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

🤖 Generated with Claude Code

flearc and others added 5 commits June 24, 2026 19:24
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…fixes)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…lector

i=1 in the path-handler string→name conversion; unblocks descendent-operator
case003/005 and quoted-selectors case002 (+3 official). Obscure ("x").y
paren-literal-head edge accepted (parser collapses the parens).
@flearc flearc merged commit a0a2a04 into main Jun 24, 2026
1 check passed
@flearc flearc deleted the feature/m6b-keeparray branch June 24, 2026 12:44
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