Skip to content

Commit 67a46cf

Browse files
authored
fix: avoid errors when parsing empty sourcemap (#165)
1 parent 56911f2 commit 67a46cf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

crates/artifacts/solc/src/sourcemap.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,9 @@ pub struct Parser<'input> {
422422
impl<'input> Parser<'input> {
423423
pub fn new(input: &'input str) -> Self {
424424
Self {
425+
done: input.is_empty(),
425426
stream: TokenStream::new(input),
426427
last_element: None,
427-
done: false,
428428
#[cfg(test)]
429429
output: None,
430430
}
@@ -594,4 +594,10 @@ mod tests {
594594
let _map = parser.collect::<Result<SourceMap, _>>().unwrap();
595595
assert_eq!(out, s);
596596
}
597+
598+
#[test]
599+
fn can_parse_empty() {
600+
let s = Parser::new("").collect::<Result<SourceMap, _>>().unwrap();
601+
assert_eq!(s.len(), 0);
602+
}
597603
}

0 commit comments

Comments
 (0)