Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add duplicate key check for mappings (hashes) #32

Merged
merged 2 commits into from

2 participants

Hilko Bengen Karen Etheridge
Hilko Bengen

No description provided.

Karen Etheridge

nice!

Karen Etheridge karenetheridge merged commit ef6e37e into from
Karen Etheridge

released in 1.63.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
4 lib/YAML/Tiny.pm
View
@@ -509,6 +509,10 @@ sub _load_hash {
die \"YAML::Tiny failed to classify line '$lines->[0]'";
}
+ if ( exists $hash->{$key} ) {
+ die \"YAML::Tiny found a duplicate key '$key' in line '$lines->[0]'";
+ }
+
# Do we have a value?
if ( length $lines->[0] ) {
# Yes
1  t/lib/TestBridge.pm
View
@@ -38,6 +38,7 @@ my %ERROR = (
E_FEATURE => qr{\QYAML::Tiny does not support a feature},
E_PLAIN => qr{\QYAML::Tiny found illegal characters in plain scalar},
E_CLASSIFY => qr{\QYAML::Tiny failed to classify the line},
+ E_DUPKEY => qr{\QYAML::Tiny found a duplicate key},
);
# use XXX -with => 'YAML::XS';
6 t/tml-local/load-error/document.tml
View
@@ -3,3 +3,9 @@
\--- foo
a: 1
--- error: E_CLASSIFY
+
+=== mapping with double key
+--- yaml
+foo: 1
+foo: 2
+--- error: E_DUPKEY
Something went wrong with that request. Please try again.