Closed achamberlin-lendup closed 7 years ago
Thanks for the report (and the patch). You're right, that is a bug. I had no computer with me over the weekend, but I spent some time thinking through the issue and have identified a few things I need to consider before deciding how to proceed. I'd be interested to hear your thoughts on them:
This would mean that only callers using the default map factory will see this change in behavior. Callers who provide their own MapFactory will not benefit from this fix, and indeed, checking for duplicate keys will probably need to become part of the contract of CollectionBuilder.
re: 1 & 2 yes, I think sets should raise an exception if they contain non-unique values, and that maps regardless of their values should only contain a key once.
FYI in my case, we use edn as a configuration file format and duplicate map keys led to an ambiguous configuration that would have been better off failing at parse time.
re: 3 I'm not that familiar with the edn-java
codebase. My PR was more of a guess, and if you need to reject it in order to fix the issue in a more general way, no offense taken.
@bpsm is there any line-of-sight to addressing this issue?
I see your concern about 3.) above, but having this safety in the DefaultMapFactory
is better than none at all.
I'm hoping to release 0.5.0 this weekend, which will include a fix for this issue.
fixed in 0.5.0
{:a 1 :a 2}
parses without error inedn-java
whereas
The edn spec states that keys should appear "at most once" so I think an error should be reported in this scenario.