Skip to content

Commit

Permalink
Merge pull request #416 from epage/dot
Browse files Browse the repository at this point in the history
fix(parser): Detect more duplicate tables
  • Loading branch information
epage committed Jan 3, 2023
2 parents c539e54 + ee4af92 commit 2c00cfd
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
7 changes: 7 additions & 0 deletions crates/toml_edit/src/parser/state.rs
Expand Up @@ -202,6 +202,13 @@ impl ParseState {
table = last_child;
}
Item::Table(ref mut sweet_child_of_mine) => {
// "Likewise, using dotted keys to redefine tables already defined in [table] form is not allowed"
if dotted && !sweet_child_of_mine.is_implicit() {
return Err(CustomError::DuplicateKey {
key: key.get().into(),
table: None,
});
}
table = sweet_child_of_mine;
}
_ => unreachable!(),
Expand Down
7 changes: 1 addition & 6 deletions crates/toml_edit/tests/decoder_compliance.rs
Expand Up @@ -3,11 +3,6 @@ mod decoder;
fn main() {
let decoder = decoder::Decoder;
let mut harness = toml_test_harness::DecoderHarness::new(decoder);
harness
.ignore([
"invalid/control/comment-cr.toml",
"invalid/table/append-with-dotted-keys-2.toml",
])
.unwrap();
harness.ignore(["invalid/control/comment-cr.toml"]).unwrap();
harness.test();
}
Expand Up @@ -2,4 +2,4 @@ TOML parse error at line 17, column 3
|
17 | b.c.t = "Using dotted keys to add to [a.b.c] after explicitly defining it above is not allowed"
| ^
Duplicate key `t`
Duplicate key `c`
@@ -0,0 +1,5 @@
TOML parse error at line 8, column 3
|
8 | b.c.d.k.t = "Using dotted keys to add to [a.b.c.d] after explicitly defining it above is not allowed"
| ^
Duplicate key `d`

0 comments on commit 2c00cfd

Please sign in to comment.