Skip to content

Commit a510d88

Browse files
authored
Merge pull request swiftlang#213 from akyrtzi/clearer-parser-compatibility-error
[SyntaxParser] Provide clearer error message (and code comments) for the 'parser compatibility' error
2 parents c74a8d3 + ccd1b7e commit a510d88

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Sources/SwiftSyntax/SyntaxParser.swift

+9-3
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,30 @@ public enum ParserError: Error, CustomStringConvertible {
3939
/// normal circumstances, and it should be reported as a bug.
4040
case invalidSyntaxData
4141

42-
/// The SwiftSyntax parser library isn't compatible with this client
42+
/// The SwiftSyntax parser library isn't compatible with this SwiftSyntax version.
43+
///
44+
/// Incompatibility can occur if the loaded `lib_InternalSwiftSyntaxParser.dylib/.so`
45+
/// is from a toolchain that is not compatible with this version of SwiftSyntax.
4346
case parserCompatibilityCheckFailed
4447

4548
public var description: String {
4649
switch self {
4750
case .invalidSyntaxData:
4851
return "parser created invalid syntax data"
4952
case .parserCompatibilityCheckFailed:
50-
return "SwiftSyntax parser library isn't compatible"
53+
return "The loaded '_InternalSwiftSyntaxParser' library is from a toolchain that is not compatible with this version of SwiftSyntax"
5154
}
5255
}
5356
}
5457

5558
/// Namespace for functions to parse swift source and retrieve a syntax tree.
5659
public enum SyntaxParser {
5760

58-
/// True if the parser library is compatible with the SwiftSyntax client;
61+
/// True if the parser library is compatible with this SwiftSyntax version;
5962
/// false otherwise.
63+
///
64+
/// Incompatibility can occur if the loaded `lib_InternalSwiftSyntaxParser.dylib/.so`
65+
/// is from a toolchain that is not compatible with this version of SwiftSyntax.
6066
fileprivate static var nodeHashVerifyResult: Bool = verifyNodeDeclarationHash()
6167

6268
/// Parses the string into a full-fidelity Syntax tree.

0 commit comments

Comments
 (0)