-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
functions that use .call() should be allowed to declared view or defa…
…ult mutability Neither option should produce a diagnostic. Fixes #997 Signed-off-by: Sean Young <[email protected]>
- Loading branch information
Showing
8 changed files
with
173 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
|
||
contract bar { | ||
function test(uint128 v) public returns (bool) { | ||
return msg.value > v; | ||
} | ||
} | ||
contract bar { | ||
uint128 state; | ||
function test(uint128 v) public returns (bool) { | ||
return state > v; | ||
} | ||
} | ||
// ---- Expect: diagnostics ---- | ||
// warning: 3:13-59: function can be declared 'pure' | ||
// warning: 3:2-48: function can be declared 'view' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
tests/contract_testcases/substrate/functions/mutability_12.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
contract c { | ||
// private functions cannot be payable and solc checks msg.value as | ||
// state read in them | ||
function foo() private view returns (uint) { | ||
return msg.value; | ||
} | ||
|
||
function bar() public returns (uint) { | ||
return foo(); | ||
} | ||
} | ||
|
||
// ---- Expect: diagnostics ---- | ||
// warning: 8:2-38: function can be declared 'view' |
24 changes: 16 additions & 8 deletions
24
tests/contract_testcases/substrate/modifier/mutability_01.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
contract c { | ||
uint128 var; | ||
modifier foo1() { uint128 x = var; _; } | ||
modifier foo2() { var = 2; _; } | ||
modifier foo3() { var = msg.value; _; } | ||
|
||
contract c { | ||
uint64 var; | ||
modifier foo() { uint64 x = var; _; } | ||
|
||
function bar() foo() public pure {} | ||
} | ||
function bar1() foo1() public pure {} | ||
function bar2() foo2() public view {} | ||
function bar3() foo3() public {} | ||
} | ||
// ---- Expect: diagnostics ---- | ||
// warning: 4:37-38: local variable 'x' has been assigned, but never read | ||
// error: 4:41-44: function declared 'pure' but this expression reads from state | ||
// warning: 3:31-32: local variable 'x' has been assigned, but never read | ||
// error: 7:21-27: function declared 'pure' but modifier reads from state | ||
// note 3:35-38: read to state | ||
// error: 8:21-27: function declared 'view' but modifier writes to state | ||
// note 4:23-26: write to state | ||
// error: 9:21-27: function declared 'nonpayable' but modifier accesses value sent, which is only allowed for payable functions | ||
// note 5:29-38: access of value sent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters