mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #6320 from ethereum/callvalue_nonpayable
Inline Assembly: Issue error for callvalue in nonpayable function
This commit is contained in:
@@ -3,4 +3,4 @@ contract C {
|
||||
function f() costs(1 ether) public view {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (101-115): This modifier uses "msg.value" and thus the function has to be payable or internal.
|
||||
// TypeError: (101-115): This modifier uses "msg.value" or "callvalue()" and thus the function has to be payable or internal.
|
||||
|
||||
+1
-1
@@ -4,4 +4,4 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (52-61): "msg.value" can only be used in payable public functions. Make the function "payable" or use an internal function to avoid this error.
|
||||
// TypeError: (52-61): "msg.value" and "callvalue()" can only be used in payable public functions. Make the function "payable" or use an internal function to avoid this error.
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
contract C
|
||||
{
|
||||
function () external {
|
||||
uint x;
|
||||
assembly {
|
||||
x := callvalue()
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (92-103): "msg.value" and "callvalue()" can only be used in payable public functions. Make the function "payable" or use an internal function to avoid this error.
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public {
|
||||
assembly {
|
||||
x := callvalue()
|
||||
}
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (81-92): "msg.value" and "callvalue()" can only be used in payable public functions. Make the function "payable" or use an internal function to avoid this error.
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
contract C
|
||||
{
|
||||
function f() internal returns (uint x) {
|
||||
assembly {
|
||||
x := callvalue()
|
||||
}
|
||||
}
|
||||
function g() public returns (uint) {
|
||||
return f();
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
contract C
|
||||
{
|
||||
modifier m {
|
||||
uint x;
|
||||
assembly {
|
||||
x := callvalue()
|
||||
}
|
||||
_;
|
||||
}
|
||||
function f() m public {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (99-100): This modifier uses "msg.value" or "callvalue()" and thus the function has to be payable or internal.
|
||||
@@ -0,0 +1,9 @@
|
||||
contract C
|
||||
{
|
||||
function () external payable {
|
||||
uint x;
|
||||
assembly {
|
||||
x := callvalue()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
contract C
|
||||
{
|
||||
function f(uint x) public payable {
|
||||
assembly {
|
||||
x := callvalue()
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
contract C
|
||||
{
|
||||
modifier m {
|
||||
uint x;
|
||||
assembly {
|
||||
x := callvalue()
|
||||
}
|
||||
_;
|
||||
}
|
||||
function f() m public payable {
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,4 @@ contract C {
|
||||
function f() m(1 ether, msg.value) public view {}
|
||||
}
|
||||
// ----
|
||||
// TypeError: (118-127): "msg.value" can only be used in payable public functions. Make the function "payable" or use an internal function to avoid this error.
|
||||
// TypeError: (118-127): "msg.value" and "callvalue()" can only be used in payable public functions. Make the function "payable" or use an internal function to avoid this error.
|
||||
|
||||
Reference in New Issue
Block a user