Skip to content

Commit

Permalink
fix(coverage): better find of loc start byte position (#8958)
Browse files Browse the repository at this point in the history
  • Loading branch information
grandizzy authored Sep 25, 2024
1 parent 883bb1c commit 8d5a66d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/evm/coverage/src/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,14 @@ impl<'a> ContractVisitor<'a> {
}

fn source_location_for(&self, loc: &ast::LowFidelitySourceLocation) -> SourceLocation {
let loc_start =
self.source.char_indices().map(|(i, _)| i).nth(loc.start).unwrap_or_default();
SourceLocation {
source_id: self.source_id,
contract_name: self.contract_name.clone(),
start: loc.start as u32,
length: loc.length.map(|x| x as u32),
line: self.source[..loc.start].lines().count(),
line: self.source[..loc_start].lines().count(),
}
}
}
Expand Down

0 comments on commit 8d5a66d

Please sign in to comment.