Skip to content

Add C-380: json.to_map holds one entry per key - #141

Merged
O6lvl4 merged 6 commits into
mainfrom
contract-json-to-map-dup-keys
Oct 14, 2026
Merged

O6lvl4 merged 6 commits into
mainfrom
contract-json-to-map-dup-keys

Conversation

@O6lvl4

@O6lvl4 O6lvl4 commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Adds C-380 under ALS-C1: json.to_map folds an object's fields into the map one upsert at a time. A repeated key therefore keeps the position of its first occurrence and takes the value of its last, so the map holds it once.

The judge side of almide/almide#3700. On wasm today, json.to_map(value.object([("k", 1), ("k", 2)])) answers ["k": "1", "k": "2"]: len is 2, get returns the first value, and == against ["k": "2"] is false. Native answers ["k": "2"].

  • Contract C-380 pins three rules:
    • one entry per key (first position, last value);
    • a Str field is taken verbatim, any other value is its value.stringify text;
    • a non-object is none.
  • Fixture spec/wasm_cross/json_to_map_duplicate_keys.almd covers a repeated key, first-position order, mixed non-Str values, a json.parsed duplicate, an empty object, a non-object, and equality against the deduplicated map.
  • Reference evaluator fix. json.to_map in the evaluator answered none for any non-Str value and did not deduplicate. It now follows C-380, and its output on the fixture is byte-identical to almide native (develop 5cbe703c5).
  • Provenance. Only C-380's row is added. A full --write also rewrites older rows whose entry commits moved when their PRs were rebase-merged, so that unrelated churn is left out.

Gates run locally, all green: check-contracts, contract-provenance, als-element-coverage, als-style, als-validation, links, gate-verification, selftest-conformance, runner-coverage.

The wasm leg of the fixture fails on almide today. That is the defect; the implementation PR follows the pin advance.

O6lvl4 and others added 6 commits October 14, 2026 08:56
…e reference evaluator's json.to_map

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
…y fixture

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@O6lvl4
O6lvl4 merged commit f4f29fb into main Oct 14, 2026
1 check passed
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