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

Duplicated keys in record #24

Closed
eapyl opened this issue Feb 25, 2022 · 2 comments · Fixed by #25
Closed

Duplicated keys in record #24

eapyl opened this issue Feb 25, 2022 · 2 comments · Fixed by #25
Labels
bug Something isn't working

Comments

@eapyl
Copy link

eapyl commented Feb 25, 2022

Hello,

It seems like the library ignores duplicated keys silently

root:
  item1:
    name: Item1
  item1:
    name: Item 2

and it seems like cause Dict.fromList is used on the list without duplication check. Is it expected behavior?
It feels for me that it should produce an error in such cases. Or am I wrong?
Thanks

@MaybeJustJames
Copy link
Owner

Hi @eapyl Indeed you are right. I'm following pyyaml behaviour here but, as pointed out in this bug, the yaml spec says keys should be unique.

The problem should probably be caught earlier, in the parsing step (e.g. https://github.com/MaybeJustJames/yaml/blob/2.1.0/src/Yaml/Parser.elm#L454) since, at decode time, we no longer know there are duplicate keys.

I would gladly accept a PR for this because I probably won't be able to fix this in the near term

@MaybeJustJames MaybeJustJames added the bug Something isn't working label Feb 26, 2022
@ypyl
Copy link

ypyl commented Feb 26, 2022

Hello @MaybeJustJames, thank you for pointing out the source code where it can be fixed.
I have prepared a small PR. Could you please check it and comment? thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants