mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
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:
parent
8f62eeaf7e
commit
0b8e68f70d
68 changed files with 1011 additions and 229 deletions
|
@ -290,6 +290,10 @@ fn chomp_integer_part(buffer: &[u8]) -> Result<&str, Progress> {
|
|||
)
|
||||
}
|
||||
|
||||
fn is_plausible_ident_continue(ch: char) -> bool {
|
||||
ch == '_' || is_alnum(ch)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn chomp_part<F, G>(leading_is_good: F, rest_is_good: G, buffer: &[u8]) -> Result<&str, Progress>
|
||||
where
|
||||
|
@ -317,6 +321,15 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
if let Ok((next, _width)) = char::from_utf8_slice_start(&buffer[chomped..]) {
|
||||
// This would mean we have e.g.:
|
||||
// * identifier followed by a _
|
||||
// * an integer followed by an alphabetic char
|
||||
if is_plausible_ident_continue(next) {
|
||||
return Err(NoProgress);
|
||||
}
|
||||
}
|
||||
|
||||
if chomped == 0 {
|
||||
Err(NoProgress)
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue