Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect duplicate keys of mapping nodes #141

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

sstroemer
Copy link

This (at least partially) fixes #140 by checking for the existence of a key before inserting it into mapping, which requires the dicttype to implement setindex! (since it's inside the try catch I thought it was safe to just assume that all "proper dicttypes" should support that, would otherwise just get caught).

I suppose that "bug fix" could be potentially seen as breaking change to some code bases (but maybe a good one?), which is why I've opted to do it in a non-breaking way, defaulting to not throwing and sticking to the previous behavior. Could be worth to consider always throwing here though...

src/constructor.jl Outdated Show resolved Hide resolved
Copy link
Collaborator

@kescobo kescobo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with this approach, but given the clarity of the spec, this does seem like a clear bug, which IMO could be fixed in a patch release even if it breaks existing code - that code shouldn't work.

That said, I can also see the argument for this approach which gives folks a flashing red light, but doesn't stop their code from running. I don't feel strongly one way or the other.

…epending on `strict_unique_keys`

Co-authored-by: Kevin Bonham <[email protected]>
@GunnarFarneback
Copy link
Contributor

GunnarFarneback commented Jun 12, 2024

Depending on implementation details, this may or may not conflict with the override functionality of merge tags, https://yaml.org/type/merge.html.

Edit: It's probably fine since there's a merge test which doesn't fail.

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.

Duplicate keys in mapping
3 participants