@@ -845,7 +845,10 @@ extension Lexer.Cursor {
845845 }
846846
847847 func isRightBound( isLeftBound: Bool ) -> Bool {
848- switch self . peek ( ) {
848+ guard let c = self . peek ( ) else {
849+ return false // last char in file
850+ }
851+ switch c {
849852 case " " , " \r " , " \n " , " \t " , // whitespace
850853 " ) " , " ] " , " } " , // closing delimiters
851854 " , " , " ; " , " : " : // expression separators
@@ -875,8 +878,6 @@ extension Lexer.Cursor {
875878 } else {
876879 return true
877880 }
878- case nil :
879- return false // last char in file
880881 default :
881882 return true
882883 }
@@ -890,7 +891,10 @@ extension Lexer.Cursor {
890891 sourceBufferStart: Lexer . Cursor ,
891892 preferRegexOverBinaryOperator: Bool
892893 ) -> Lexer . Result {
893- switch self . peek ( ) {
894+ guard let c = self . peek ( ) else {
895+ return Lexer . Result ( . endOfFile)
896+ }
897+ switch c {
894898 case " @ " : _ = self . advance ( ) ; return Lexer . Result ( . atSign)
895899 case " { " : _ = self . advance ( ) ; return Lexer . Result ( . leftBrace)
896900 case " [ " : _ = self . advance ( ) ; return Lexer . Result ( . leftSquare)
@@ -960,8 +964,6 @@ extension Lexer.Cursor {
960964
961965 case " ` " :
962966 return self . lexEscapedIdentifier ( )
963- case nil :
964- return Lexer . Result ( . endOfFile)
965967 default :
966968 var tmp = self
967969 if tmp. advance ( if: { Unicode . Scalar ( $0) . isValidIdentifierStartCodePoint } ) {
0 commit comments