Hacktoberfest 2026: die Issues, die Maintainer für den Oktober markiert haben – offen und einsteigerfreundlich. Hacktoberfest-Issues durchsuchen

Don't let users attempt to alias/merge arrays

Offen
#349 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
35/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
ruby
Bereich
backend

Rechercherichtung

Start with the YAML.load example and inspect how Psych handles an alias used with the << merge key when the aliased value is an array. The change is done when this invalid array merge is rejected with an error instead of producing a hash containing the literal << key.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

I encountered the confusing behavior described below because I didn't realize that one couldn't merge arrays, only maps. Perhaps we should instead make the parser more strict and throw an error rather than producing the unexpected object structure?

The confusing behavior:

YAML.load("
# Bad! can't merge alias/arrays
foo: &foo  
  - a: 1
bar: 
  <<: *foo
")

=> {"foo"=>[{"a"=>1}], "bar"=>{"<<"=>[{"a"=>1}]}}

Note the appearance of the odd <<. I was expecting expected

   {"foo"=>[{"a"=>1}], "bar"=>[{"a"=>1}]}

As discussed here, my error is that the problem is that &foo is an attempted alias for an array. It would have been ideal if the parser had indicated my error instead.

In case relevant:

ENV['RBENV_VERSION']
=> "2.4"
YAML.libyaml_version
=> [0, 1, 4]

(Also, not entirely sure if this request belongs here or at https://github.com/yaml/libyaml , please feel free to redirect me!)

Vorherrschende Sprache
Ruby
Sterne
596
Forks
224
Ø Merge
8 Std. 38 Min.
Gemergte PRs (30 T.)
2

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus ruby/psych

Alle Issues in ruby/psych

Ähnliche Issues

Weitere Issues zu Ruby

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.