Skip to content

Commit

Permalink
Also fix for true and false
Browse files Browse the repository at this point in the history
  • Loading branch information
juntyr committed Sep 5, 2023
1 parent 19d5ab7 commit b5655bf
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add support for byte literals as strongly typed unsigned 8-bit integers ([#438](https://github.com/ron-rs/ron/pull/438))
- Fix issue [#321](https://github.com/ron-rs/ron/issues/321) and allow parsing UTF-8 identifiers ([#488](https://github.com/ron-rs/ron/pull/488))
- Breaking: Enforce that ron always writes valid UTF-8 ([#488](https://github.com/ron-rs/ron/pull/488))
- Fix parsing of struct/variant names starting in `None` or `Some` ([#499](https://github.com/ron-rs/ron/pull/499))
- Fix parsing of struct/variant names starting in `None`, `Some`, `true`, or `false` ([#499](https://github.com/ron-rs/ron/pull/499))

## [0.8.1] - 2023-08-17

Expand Down
18 changes: 18 additions & 0 deletions src/de/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,21 @@ fn test_remainder() {
assert_eq!(deserializer.remainder(), " 37 ");
assert_eq!(deserializer.end(), Err(Error::TrailingCharacters));
}

#[test]
fn boolean_struct_name() {
check_from_str_bytes_reader::<bool>(
"true_",
Err(SpannedError {
code: Error::ExpectedBoolean,
position: Position { line: 1, col: 1 },
}),
);
check_from_str_bytes_reader::<bool>(
"false_",
Err(SpannedError {
code: Error::ExpectedBoolean,
position: Position { line: 1, col: 1 },
}),
);
}
4 changes: 2 additions & 2 deletions src/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,9 +478,9 @@ impl<'a> Parser<'a> {
}

pub fn bool(&mut self) -> Result<bool> {
if self.consume_str("true") {
if self.consume_ident("true") {
Ok(true)
} else if self.consume_str("false") {
} else if self.consume_ident("false") {
Ok(false)
} else {
Err(Error::ExpectedBoolean)
Expand Down

0 comments on commit b5655bf

Please sign in to comment.