mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 07:41:12 +00:00
Give parser fuzzing some TLC
* The header + expr fuzzers can both be run again (header fuzzer had regressed). * I ran the expr fuzzer for ~60 seconds with no additional panics uncovered * "tab_crash" hit supposedly unreachable code in blankspace.rs - and I went to the liberty of dramatically simplifying all that code, rather than just trying to fix the bug * Other failures were straight-forward error cases that should have been handled (and passed up the chain) instead of panicking
This commit is contained in:
parent
521afce1f4
commit
5f29402297
15 changed files with 176 additions and 475 deletions
|
@ -64,7 +64,7 @@ pub enum SyntaxError<'a> {
|
|||
Space(BadInputError),
|
||||
NotEndOfFile(Position),
|
||||
}
|
||||
pub trait SpaceProblem {
|
||||
pub trait SpaceProblem: std::fmt::Debug {
|
||||
fn space_problem(e: BadInputError, pos: Position) -> Self;
|
||||
}
|
||||
|
||||
|
@ -265,6 +265,8 @@ pub enum EGeneratesWith {
|
|||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum BadInputError {
|
||||
HasTab,
|
||||
HasMisplacedCarriageReturn,
|
||||
HasAsciiControl,
|
||||
///
|
||||
TooManyLines,
|
||||
///
|
||||
|
@ -272,15 +274,6 @@ pub enum BadInputError {
|
|||
BadUtf8,
|
||||
}
|
||||
|
||||
pub fn bad_input_to_syntax_error<'a>(bad_input: BadInputError) -> SyntaxError<'a> {
|
||||
use crate::parser::BadInputError::*;
|
||||
match bad_input {
|
||||
HasTab => SyntaxError::NotYetImplemented("call error on tabs".to_string()),
|
||||
TooManyLines => SyntaxError::TooManyLines,
|
||||
BadUtf8 => SyntaxError::BadUtf8,
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> SourceError<'a, T> {
|
||||
pub fn new(problem: T, state: &State<'a>) -> Self {
|
||||
Self {
|
||||
|
@ -323,6 +316,8 @@ impl<'a> SyntaxError<'a> {
|
|||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum EExpr<'a> {
|
||||
TrailingOperator(Position),
|
||||
|
||||
Start(Position),
|
||||
End(Position),
|
||||
BadExprEnd(Position),
|
||||
|
@ -560,6 +555,7 @@ pub enum EPattern<'a> {
|
|||
Record(PRecord<'a>, Position),
|
||||
List(PList<'a>, Position),
|
||||
Underscore(Position),
|
||||
NotAPattern(Position),
|
||||
|
||||
Start(Position),
|
||||
End(Position),
|
||||
|
@ -773,7 +769,7 @@ pub struct FileError<'a, T> {
|
|||
pub trait Parser<'a, Output, Error> {
|
||||
fn parse(
|
||||
&self,
|
||||
alloc: &'a Bump,
|
||||
arena: &'a Bump,
|
||||
state: State<'a>,
|
||||
min_indent: u32,
|
||||
) -> ParseResult<'a, Output, Error>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue