Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

json_merge fails on nonempty objects and returns an array for two empty objects

Chiusa Adatta ai principianti
#1,248 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
85/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
c
Ambito
devtools

Direzione di ricerca

Inizia da lib/json.eigs:41–51 e dal comportamento di json_decode coperto in tests/test_json_hard.eigs. Esegui le due riproduzioni tramite src/eigenscript, quindi aggiungi la copertura per oggetti disgiunti, in conflitto e vuoti. Il lavoro è completato quando json_merge restituisce un oggetto piatto decodificato, il secondo input prevale nei conflitti e tutti i casi elencati passano.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

area:stdlib bug found-by:code-review

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.

Lingua principale
C
Stelle
3
Fork
7
Merge medio
4h 7m
PR unite (30g)
112

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di InauguralSystems/EigenScript

Tutte le issue di InauguralSystems/EigenScript

Issue simili

Altre issue su C

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.