Skip to content

Commit ddbdb6d

Browse files
committed
prevent inf loop
1 parent b1480b9 commit ddbdb6d

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

compiler/parser/src/lexer.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,18 @@ where
110110
}
111111
}
112112

113-
fn slide(&mut self) {
113+
fn slide(&mut self) -> Option<char> {
114114
self.window.rotate_left(1);
115-
*self.window.last_mut().expect("never empty") = self.source.next();
115+
let next = self.source.next();
116+
*self.window.last_mut().expect("never empty") = next;
117+
next
116118
}
117119

118120
fn fill(&mut self) {
119121
while self.window[0] == None {
120-
self.slide();
122+
if self.slide() == None {
123+
return;
124+
}
121125
}
122126
}
123127

0 commit comments

Comments
 (0)