fix(solc): flatten replacement target location (#846)

* adjust the end location

* upd changelog
This commit is contained in:
Roman Krasiuk 2022-01-31 00:08:04 -08:00 committed by GitHub
parent 01544ec4b7
commit a48496000a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 1 deletions

View File

@ -38,6 +38,8 @@
### Unreleased ### Unreleased
- Fix flatten replacement target location
[#846](https://github.com/gakonst/ethers-rs/pull/846)
- Fix duplicate files during flattening - Fix duplicate files during flattening
[#813](https://github.com/gakonst/ethers-rs/pull/813) [#813](https://github.com/gakonst/ethers-rs/pull/813)
- Add ability to flatten file imports - Add ability to flatten file imports

View File

@ -485,7 +485,8 @@ impl<T> SolDataUnit<T> {
pub fn loc_by_offset(&self, offset: isize) -> (usize, usize) { pub fn loc_by_offset(&self, offset: isize) -> (usize, usize) {
( (
offset.saturating_add(self.loc.start as isize) as usize, offset.saturating_add(self.loc.start as isize) as usize,
offset.saturating_add(self.loc.end as isize) as usize, // make the end location exclusive
offset.saturating_add(self.loc.end as isize + 1) as usize,
) )
} }
} }

View File

@ -376,4 +376,5 @@ fn can_flatten_file_with_duplicates() {
assert_eq!(result.matches("contract Foo {").count(), 1); assert_eq!(result.matches("contract Foo {").count(), 1);
assert_eq!(result.matches("contract Bar {").count(), 1); assert_eq!(result.matches("contract Bar {").count(), 1);
assert_eq!(result.matches("contract FooBar {").count(), 1); assert_eq!(result.matches("contract FooBar {").count(), 1);
assert_eq!(result.matches(";").count(), 1);
} }