Fix duplicate version directive.

This commit is contained in:
Ethiraric 2024-01-19 18:37:38 +01:00
parent 31dc4a1456
commit 308b07bad2
2 changed files with 6 additions and 2 deletions

View file

@ -498,15 +498,20 @@ impl<T: Iterator<Item = char>> Parser<T> {
}
fn parser_process_directives(&mut self) -> Result<(), ScanError> {
let mut version_directive_received = false;
loop {
let mut tags = HashMap::new();
match self.peek_token()? {
Token(_, TokenType::VersionDirective(_, _)) => {
Token(mark, TokenType::VersionDirective(_, _)) => {
// XXX parsing with warning according to spec
//if major != 1 || minor > 2 {
// return Err(ScanError::new(tok.0,
// "found incompatible YAML document"));
//}
if version_directive_received == true {
return Err(ScanError::new(*mark, "duplicate version directive"));
}
version_directive_received = true;
}
Token(mark, TokenType::TagDirective(handle, prefix)) => {
if tags.contains_key(handle) {

View file

@ -298,7 +298,6 @@ fn expected_events(expected_tree: &str) -> Vec<String> {
#[rustfmt::skip]
static EXPECTED_FAILURES: &[&str] = &[
// Directives (various)
"SF5V", // duplicate directive
"W4TN", // scalar confused as directive
// Losing trailing newline
"JEF9-02",