Skip to content

Commit

Permalink
Fixed another bug in skip_whitespace which was causing an infinite loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Howard committed Aug 10, 2020
1 parent 092b748 commit 20f3fb0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
8 changes: 3 additions & 5 deletions src/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,7 @@ impl Scanner<'_> {

/// This function is gross and it also messes up sometimes near the end of files
fn skip_whitespace(&mut self) {
loop {
if self.is_at_end() {
return;
}

while !self.is_at_end() {
let next = self.peek();
if (next == b' ') || (next == b'\t') || (next == b'\r') {
self.advance();
Expand All @@ -141,6 +137,8 @@ impl Scanner<'_> {
self.advance(); // consume the \n
self.cur_line += 1;
}
} else {
return; // Return on single slash
}
} else {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/vm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -696,9 +696,9 @@ impl VM {
return InterpretResult::InterpretRuntimeError;
}
}
OpCode::OpDivide => op_binary!(Value::Double, /),
OpCode::OpSubtract => op_binary!(Value::Double, -),
OpCode::OpMultiply => op_binary!(Value::Double, *),
OpCode::OpDivide => op_binary!(Value::Double, /),
OpCode::OpGreater => op_binary!(Value::Bool, >),
OpCode::OpLess => op_binary!(Value::Bool, <),
OpCode::OpEqual => {
Expand Down
1 change: 1 addition & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dart tool/bin/test.dart #> results.txt
1 change: 1 addition & 0 deletions tool/bin/test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ void _defineTestSuites() {

rust({
"test": "pass",
// "test/number/nan_equality.lox": "skip",
...earlyChapters,
});
}

0 comments on commit 20f3fb0

Please sign in to comment.