1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

scanner: minor cleanup of scanner.v (#7467)

This commit is contained in:
yuyi 2020-12-22 17:56:29 +08:00 committed by GitHub
parent a8447398f5
commit c11928260d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1170,10 +1170,7 @@ fn (mut s Scanner) ident_char() string {
[inline] [inline]
fn (s &Scanner) expect(want string, start_pos int) bool { fn (s &Scanner) expect(want string, start_pos int) bool {
end_pos := start_pos + want.len end_pos := start_pos + want.len
if start_pos < 0 || start_pos >= s.text.len { if start_pos < 0 || end_pos < 0 || start_pos >= s.text.len || end_pos > s.text.len {
return false
}
if end_pos < 0 || end_pos > s.text.len {
return false return false
} }
for pos in start_pos .. end_pos { for pos in start_pos .. end_pos {
@ -1273,8 +1270,7 @@ pub fn (mut s Scanner) error(msg string) {
} }
fn (mut s Scanner) vet_error(msg string) { fn (mut s Scanner) vet_error(msg string) {
eline := '$s.file_path:$s.line_nr: $msg' s.vet_errors << '$s.file_path:$s.line_nr: $msg'
s.vet_errors << eline
} }
pub fn verror(s string) { pub fn verror(s string) {