@@ -845,7 +845,10 @@ extension Lexer.Cursor {
845
845
}
846
846
847
847
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 {
849
852
case " " , " \r " , " \n " , " \t " , // whitespace
850
853
" ) " , " ] " , " } " , // closing delimiters
851
854
" , " , " ; " , " : " : // expression separators
@@ -875,8 +878,6 @@ extension Lexer.Cursor {
875
878
} else {
876
879
return true
877
880
}
878
- case nil :
879
- return false // last char in file
880
881
default :
881
882
return true
882
883
}
@@ -890,7 +891,10 @@ extension Lexer.Cursor {
890
891
sourceBufferStart: Lexer . Cursor ,
891
892
preferRegexOverBinaryOperator: Bool
892
893
) -> Lexer . Result {
893
- switch self . peek ( ) {
894
+ guard let c = self . peek ( ) else {
895
+ return Lexer . Result ( . endOfFile)
896
+ }
897
+ switch c {
894
898
case " @ " : _ = self . advance ( ) ; return Lexer . Result ( . atSign)
895
899
case " { " : _ = self . advance ( ) ; return Lexer . Result ( . leftBrace)
896
900
case " [ " : _ = self . advance ( ) ; return Lexer . Result ( . leftSquare)
@@ -960,8 +964,6 @@ extension Lexer.Cursor {
960
964
961
965
case " ` " :
962
966
return self . lexEscapedIdentifier ( )
963
- case nil :
964
- return Lexer . Result ( . endOfFile)
965
967
default :
966
968
var tmp = self
967
969
if tmp. advance ( if: { Unicode . Scalar ( $0) . isValidIdentifierStartCodePoint } ) {
0 commit comments