Skip to content

Commit

Permalink
Fix ICE with mptrs used in ABI (#868)
Browse files Browse the repository at this point in the history
Fixes #868
  • Loading branch information
cburgdorf authored Apr 12, 2023
1 parent 1c65437 commit 1ecc244
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 1 deletion.
3 changes: 2 additions & 1 deletion crates/codegen/src/db/queries/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ pub fn abi_type_maximum_size(db: &dyn CodegenDb, ty: TypeId) -> usize {
}
maximum + 32
}
ir::TypeKind::MPtr(ty) => abi_type_maximum_size(db, ty.deref(db.upcast())),

_ => unreachable!(),
}
Expand Down Expand Up @@ -155,7 +156,7 @@ pub fn abi_type_minimum_size(db: &dyn CodegenDb, ty: TypeId) -> usize {
}
minimum + 32
}

ir::TypeKind::MPtr(ty) => abi_type_minimum_size(db, ty.deref(db.upcast())),
_ => unreachable!(),
}
}
Expand Down
7 changes: 7 additions & 0 deletions crates/test-files/fixtures/crashes/mptr_field_abi.fe
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
struct Tx {
pub data: Array<u8, 320>
}

contract Foo {
pub fn bar(mut tx: Tx) {}
}
1 change: 1 addition & 0 deletions crates/tests-legacy/src/crashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ test_file! { agroce550 }
test_file! { agroce551 }
test_file! { agroce623 }
test_file! { revert_const }
test_file! { mptr_field_abi }
13 changes: 13 additions & 0 deletions newsfragments/867.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Fixed an ICE when using aggregate types with aggregate type fields in public functions

This code would previously cause an ICE:

```fe
struct Tx {
pub data: Array<u8, 320>
}
contract Foo {
pub fn bar(mut tx: Tx) {}
}
```

0 comments on commit 1ecc244

Please sign in to comment.