Skip to content

Commit

Permalink
Fix: fix more lexer fuzz failures and remove debug println
Browse files Browse the repository at this point in the history
  • Loading branch information
RDambrosio016 committed Sep 27, 2020
1 parent b8cb3f1 commit 01ba71a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
6 changes: 4 additions & 2 deletions rslint_lexer/src/lib.rs
Expand Up @@ -581,7 +581,9 @@ impl<'src> Lexer<'src> {
}
}
Some(b'0'..=b'9') => self.read_exponent(),
_ => {}
_ => {
self.next();
}
}
}
// FIXME: many engines actually allow things like `09`, but by the spec, this is not allowed
Expand Down Expand Up @@ -1102,7 +1104,7 @@ impl<'src> Lexer<'src> {
self.verify_number_end(start)
}
PRD => {
if let Some(b"..") = self.bytes.get(self.cur..self.cur + 2) {
if let Some(b"..") = self.bytes.get(self.cur + 1..self.cur + 3) {
self.cur += 3;
return tok!(DOT2, 3);
}
Expand Down
17 changes: 17 additions & 0 deletions rslint_lexer/src/tests.rs
Expand Up @@ -870,3 +870,20 @@ fn fuzz_fail_1() {
ERROR_TOKEN:2
}
}

#[test]
fn fuzz_fail_2() {
assert_lex! {
"..",
DOT:1,
DOT:1
}
}

#[test]
fn fuzz_fail_3() {
assert_lex! {
"0e",
ERROR_TOKEN:2
}
}
1 change: 0 additions & 1 deletion rslint_parser/src/tests.rs
Expand Up @@ -15,7 +15,6 @@ fn parser_smoke_test() {
}

fn test_data_dir() -> PathBuf {
println!("{:#?}", project_dir());
project_dir().join("rslint_parser/test_data")
}

Expand Down

0 comments on commit 01ba71a

Please sign in to comment.