diff --git a/CHANGELOG.md b/CHANGELOG.md index 4005e69..b5845ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 win, earlier sources win, inherited-then-local ordering) now have one source of truth. No behavior change. +### Removed + +- Remove three `Parsing.ParseError` cases that were never thrown: `emptyDocument` + (empty and comment-only documents parse to `null`), `expectedMappingKey` + (superseded by `unexpectedToken` carrying an "expected mapping key" message), + and `tabIndentation` (tabs in indentation are reported by the validation + layer's `PreflightScanner`, not the parser). No reachable behavior changes. + ### Fixed - Preserve blank lines in block scalars. The scanner dropped every blank line diff --git a/Sources/Parsing/ParseError.swift b/Sources/Parsing/ParseError.swift index a68177c..12b0f3d 100644 --- a/Sources/Parsing/ParseError.swift +++ b/Sources/Parsing/ParseError.swift @@ -1,11 +1,8 @@ public extension PureYAML.Parsing { /// Parser error with source line information when available. enum ParseError: Swift.Error, Equatable, Sendable, CustomStringConvertible { - case emptyDocument - case tabIndentation(line: Int) case unexpectedIndentation(line: Int) case mixedCollectionStyles(line: Int) - case expectedMappingKey(line: Int) case expectedAnchorName(line: Int) case expectedAliasName(line: Int) case expectedNode(line: Int, column: Int) @@ -24,16 +21,10 @@ public extension PureYAML.Parsing { public var description: String { switch self { - case .emptyDocument: - "document is empty" - case let .tabIndentation(line): - "tabs are not allowed for indentation at line \(line)" case let .unexpectedIndentation(line): "unexpected indentation at line \(line)" case let .mixedCollectionStyles(line): "mapping and sequence entries are mixed at line \(line)" - case let .expectedMappingKey(line): - "expected a mapping key at line \(line)" case let .expectedAnchorName(line): "expected an anchor name at line \(line)" case let .expectedAliasName(line): @@ -69,16 +60,10 @@ public extension PureYAML.Parsing { public var diagnosticCode: String { switch self { - case .emptyDocument: - "emptyDocument" - case .tabIndentation: - "tabIndentation" case .unexpectedIndentation: "unexpectedIndentation" case .mixedCollectionStyles: "mixedCollectionStyles" - case .expectedMappingKey: - "expectedMappingKey" case .expectedAnchorName: "expectedAnchorName" case .expectedAliasName: @@ -114,12 +99,8 @@ public extension PureYAML.Parsing { public var sourceLine: Int? { switch self { - case .emptyDocument: - nil - case let .tabIndentation(line), - let .unexpectedIndentation(line), + case let .unexpectedIndentation(line), let .mixedCollectionStyles(line), - let .expectedMappingKey(line), let .expectedAnchorName(line), let .expectedAliasName(line), let .incompatibleYAMLDirective(line), @@ -142,11 +123,8 @@ public extension PureYAML.Parsing { public var sourceColumn: Int? { switch self { - case .emptyDocument, - .tabIndentation, - .unexpectedIndentation, + case .unexpectedIndentation, .mixedCollectionStyles, - .expectedMappingKey, .expectedAnchorName, .expectedAliasName, .incompatibleYAMLDirective, diff --git a/Tests/ParsingErrorTests.swift b/Tests/ParsingErrorTests.swift index 74eeeed..8718665 100644 --- a/Tests/ParsingErrorTests.swift +++ b/Tests/ParsingErrorTests.swift @@ -46,11 +46,8 @@ struct ParsingErrorTests { @Test("Parser errors describe returned failures") func test_errorDescriptions() { - #expect(PureYAML.Parsing.ParseError.emptyDocument.description == "document is empty") - #expect(PureYAML.Parsing.ParseError.tabIndentation(line: 2).description == "tabs are not allowed for indentation at line 2") #expect(PureYAML.Parsing.ParseError.unexpectedIndentation(line: 3).description == "unexpected indentation at line 3") #expect(PureYAML.Parsing.ParseError.mixedCollectionStyles(line: 4).description == "mapping and sequence entries are mixed at line 4") - #expect(PureYAML.Parsing.ParseError.expectedMappingKey(line: 5).description == "expected a mapping key at line 5") #expect(PureYAML.Parsing.ParseError.expectedAnchorName(line: 6).description == "expected an anchor name at line 6") #expect(PureYAML.Parsing.ParseError.expectedAliasName(line: 7).description == "expected an alias name at line 7") #expect(PureYAML.Parsing.ParseError.unterminatedTag(line: 8).description == "unterminated tag at line 8")