Skip to content

Commit

Permalink
fix: avoid errors when parsing empty sourcemap (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
klkvr authored Jul 9, 2024
1 parent 56911f2 commit 67a46cf
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion crates/artifacts/solc/src/sourcemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,9 +422,9 @@ pub struct Parser<'input> {
impl<'input> Parser<'input> {
pub fn new(input: &'input str) -> Self {
Self {
done: input.is_empty(),
stream: TokenStream::new(input),
last_element: None,
done: false,
#[cfg(test)]
output: None,
}
Expand Down Expand Up @@ -594,4 +594,10 @@ mod tests {
let _map = parser.collect::<Result<SourceMap, _>>().unwrap();
assert_eq!(out, s);
}

#[test]
fn can_parse_empty() {
let s = Parser::new("").collect::<Result<SourceMap, _>>().unwrap();
assert_eq!(s.len(), 0);
}
}

0 comments on commit 67a46cf

Please sign in to comment.