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

fix(parser): Detect more duplicate tables #416

Merged
merged 1 commit into from Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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`