Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusaaguiar committed Jan 13, 2025
1 parent c3a8217 commit 54451ed
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
abstract contract C layout at 0x123 {
}
// ----
// TypeError 7587: (30-35): Storage base location cannot be specified for abstract contracts or libraries
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
contract A layout at 0x1234 {}

contract B is A {}

contract C is B layout at 0xABCD {}
// ----
// TypeError 8894: (32-50): Storage base location can only be specified in the most derived contract.
// TypeError 8894: (52-87): Storage base location can only be specified in the most derived contract.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
contract A layout at 3/2 {}
// ----
// TypeError 1763: (21-24): Contract storage base location cannot be specified by a fractional number.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
contract A layout at 0x1234 {}

contract B is A {}

contract C is B {}
// ----
// TypeError 8894: (32-50): Storage base location can only be specified in the most derived contract.
// TypeError 8894: (52-70): Storage base location can only be specified in the most derived contract.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
uint constant X = 42;
contract C layout at 0xffff * (50 - X) { }
// ----
// TypeError 6396: (43-60): Only number literals are accepted in the expression specifying the contract base storage location.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function f(uint x) returns (uint) { return x + 1; }
contract A layout at f(2) {}
// ----
// TypeError 1139: (73-77): The contract base location must be an expression that can be evaluated at compilation time.
// TypeError 6396: (73-77): Only number literals are accepted in the expression specifying the contract base storage location.
5 changes: 5 additions & 0 deletions test/libsolidity/syntaxTests/contractBaseLocation/library.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
library L layout at 0x123 {
function f() public pure { }
}
// ----
// TypeError 7587: (20-25): Storage base location cannot be specified for abstract contracts or libraries
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
contract A layout at 0x1234 {}
contract B layout at 1024 {}
contract C layout at "C" {}
contract C layout at 0 {}
// ----

0 comments on commit 54451ed

Please sign in to comment.