Skip to content

Commit 88eb8eb

Browse files
committed
Run the diagnostic formatter during round-trip testing
This allows us to reduce crashes in the diagnostic formatter
1 parent 168cc2d commit 88eb8eb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/swift-parser-cli/swift-parser-cli.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,19 @@ class VerifyRoundTrip: ParsableCommand {
134134
) throws {
135135
let tree = Parser.parse(source: source)
136136

137-
_ = ParseDiagnosticsGenerator.diagnostics(for: tree)
137+
var diags = ParseDiagnosticsGenerator.diagnostics(for: tree)
138138

139139
let resultTree: Syntax
140140
if foldSequences {
141-
resultTree = foldAllSequences(tree).0
141+
let folded = foldAllSequences(tree)
142+
resultTree = folded.0
143+
diags += folded.1
142144
} else {
143145
resultTree = Syntax(tree)
144146
}
145147

148+
_ = DiagnosticsFormatter.annotatedSource(tree: tree, diags: diags)
149+
146150
if resultTree.syntaxTextBytes != [UInt8](source) {
147151
throw Error.roundTripFailed
148152
}

0 commit comments

Comments
 (0)