@@ -34,13 +34,13 @@ public enum ParserError: Error, CustomStringConvertible {
3434 case invalidSyntaxData
3535
3636 /// The SwiftSyntax parser library isn't compatible with this client
37- case hashVerificationFailed
37+ case parserCompatibilityCheckFailed
3838
3939 public var description : String {
4040 switch self {
4141 case . invalidSyntaxData:
4242 return " parser created invalid syntax data "
43- case . hashVerificationFailed :
43+ case . parserCompatibilityCheckFailed :
4444 return " SwiftSyntax parser library isn't compatible "
4545 }
4646 }
@@ -83,13 +83,16 @@ public struct SyntaxParser {
8383 source: String ,
8484 parseLookup: IncrementalParseLookup ? = nil
8585 ) throws -> SourceFileSyntax {
86+ guard nodeHashVerifyResult else {
87+ throw ParserError . parserCompatibilityCheckFailed
88+ }
8689 // Get a native UTF8 string for efficient indexing with UTF8 byte offsets.
8790 // If the string is backed by an NSString then such indexing will become
8891 // extremely slow.
8992 var utf8Source = source
9093 utf8Source. makeNativeUTF8IfNeeded ( )
9194
92- let rawSyntax = try parseRaw ( utf8Source, parseLookup: parseLookup)
95+ let rawSyntax = parseRaw ( utf8Source, parseLookup: parseLookup)
9396
9497 guard let file = makeSyntax ( rawSyntax) as? SourceFileSyntax else {
9598 throw ParserError . invalidSyntaxData
@@ -117,11 +120,8 @@ public struct SyntaxParser {
117120 private static func parseRaw(
118121 _ source: String ,
119122 parseLookup: IncrementalParseLookup ?
120- ) throws -> RawSyntax {
123+ ) -> RawSyntax {
121124 assert ( source. isNativeUTF8)
122- guard nodeHashVerifyResult else {
123- throw ParserError . hashVerificationFailed
124- }
125125 let c_parser = swiftparse_parser_create ( )
126126 defer {
127127 swiftparse_parser_dispose ( c_parser)
0 commit comments