json_merge fails on nonempty objects and returns an array for two empty objects
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
Research direction
Start with lib/json.eigs:41–51 and the json_decode behavior covered in tests/test_json_hard.eigs. Run the two reproductions through src/eigenscript, then add coverage for disjoint, conflicting, and empty objects. Done means json_merge returns a decoded flat object, with the second input winning conflicts, and all listed cases pass.
Written by the indexing model from the issue text.
Description
json.json_merge fails on ordinary nonempty JSON objects. When both inputs are empty objects, it silently returns the wrong JSON type: an array.
Reproduce
src/eigenscript -e 'import json
print of (json.json_merge of ["{\"a\":1}", "{\"b\":2}"])'
Actual: exit 1, Error line 48: cannot index dict, at append of [merged, obj_a[i]].
Expected: a JSON object containing a: 1 and b: 2.
The empty-input case also fails the contract:
src/eigenscript -e 'import json
print of (json.json_merge of ["{}", "{}"])'
Actual: [] (exit 0). Expected: {}.
Cause and coverage
lib/json.eigs:41–51 documents an object merge in which the second object overwrites matching keys, but initializes merged as a list and integer-indexes the decoded objects. json_decode returns dictionaries for objects; that behavior is already tested. The library API promises to merge two objects.
No existing test calls the library's json_merge. Add coverage for disjoint keys, conflicting keys with the second input winning, either side empty, and both sides empty. Compare decoded objects so serialization whitespace or key ordering is not the oracle. Deep-merge semantics are outside this defect; the implementation explicitly promises a flat merge.
Confirmed with a fresh default release build of b91768e23c5a874a64e76e4af9ab291e6aa49983, with inherited EIGS_* variables removed.
- Dominant language
- C
- Stars
- 3
- Forks
- 7
- Avg merge
- 4h 7m
- Merged PRs (30d)
- 112
Getting set up
Starts the project's dev container in your browser, under your own GitHub account.
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from InauguralSystems/EigenScript
-
area:embed kind:silent-wrong
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
InauguralSystems/EigenScript#1387 ·
Maintainers usually reply within 1 day
-
area:stdlib kind:silent-wrong
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
InauguralSystems/EigenScript#1378 ·
Maintainers usually reply within 1 day
-
area:gates kind:gate-defect
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
InauguralSystems/EigenScript#1374 ·
Maintainers usually reply within 1 day
-
Error carets pad multi-byte UTF-8 byte-for-byte, so the ^ lands right of the token on a terminalOpenarea:lint-tooling kind:silent-wrong
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
InauguralSystems/EigenScript#1373 ·
Maintainers usually reply within 1 day
-
area:gates kind:docs-drift
Difficulty 1/5 Under an hour Newbie friendliness 88/100
InauguralSystems/EigenScript#1372 ·
Maintainers usually reply within 1 day
All issues in InauguralSystems/EigenScript
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
BasedHardware/omi#19711 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
microsoft/ebpf-for-windows#5604 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
trezor/trezor-firmware#7985 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 2 days