Fix approximately a bajillion fmt and parsing bugs

(discovered by fuzzing)

There's more to come, but this seems like a good batch for now.
This commit is contained in:
Joshua Warner 2023-01-11 19:44:29 -08:00
parent 8f62eeaf7e
commit 0b8e68f70d
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
68 changed files with 1011 additions and 229 deletions

View file

@ -19,9 +19,9 @@ mod test_parse {
use bumpalo::collections::vec::Vec;
use bumpalo::{self, Bump};
use roc_parse::ast::Expr::{self, *};
use roc_parse::ast::StrLiteral::*;
use roc_parse::ast::StrSegment::*;
use roc_parse::ast::{self, EscapedChar};
use roc_parse::ast::{CommentOrNewline, StrLiteral::*};
use roc_parse::module::module_defs;
use roc_parse::parser::{Parser, SyntaxError};
use roc_parse::state::State;
@ -322,6 +322,22 @@ mod test_parse {
assert_eq!(std::mem::size_of::<roc_parse::ast::Expr>(), 40);
}
#[test]
fn parse_two_line_comment_with_crlf() {
let src = "# foo\r\n# bar\r\n42";
assert_parses_to(
src,
Expr::SpaceBefore(
&Expr::Num("42"),
&[
CommentOrNewline::LineComment(" foo"),
// We used to have a bug where there was an extra CommentOrNewline::Newline between these.
CommentOrNewline::LineComment(" bar"),
],
),
);
}
// PARSE ERROR
// TODO this should be parse error, but isn't!