Skip to content

add warning when duplicate hashmap key - #185

Open
higuruchi wants to merge 1 commit into
chyh1990:masterfrom
higuruchi:duplicated-hash-key-warning
Open

higuruchi wants to merge 1 commit into
chyh1990:masterfrom
higuruchi:duplicated-hash-key-warning

Conversation

@higuruchi

Copy link
Copy Markdown

Close: #174

Add warning when duplicate hashmap key

  • yaml

    key1: 
      a: "b"
    key1: 
      b: "c"
  • warning

    WARNING: Hash({String("b"): String("c")}) is duplicated
    

@puetzp

puetzp commented Feb 4, 2022

Copy link
Copy Markdown

Hey there, I wonder if insert_new_node should return a ScanError instead of a waning in case of encountering a duplicate key. It seems to me that the YAML 1.2 spec contains numerous sections that mention the requirement of key uniqueness in mappings, which would indicate a "hard" error.

@davvid

davvid commented Jan 29, 2024

Copy link
Copy Markdown

👍 on the above, and also note that since this is library code we shouldn't really be printing anything.

I'd be more than happy to accept a PR that makes duplicate keys an error in my fork: https://github.com/davvid/yaml-rust

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.

Dupliacte keys are not detected as invalid YAML

3 participants