mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #3086 from ethereum/allow_gas_in_view
Allow ``gas`` in view functions.
This commit is contained in:
commit
18a72dbe46
@ -19,6 +19,7 @@ Bugfixes:
|
|||||||
(such as ``balance``, ``transfer``, etc.)
|
(such as ``balance``, ``transfer``, etc.)
|
||||||
* Type Checker: Prevent duplicate event declarations.
|
* Type Checker: Prevent duplicate event declarations.
|
||||||
* Type Checker: Do not mark event parameters as shadowing state variables.
|
* Type Checker: Do not mark event parameters as shadowing state variables.
|
||||||
|
* Type Checker: Allow ``gas`` in view functions.
|
||||||
|
|
||||||
### 0.4.17 (2017-09-21)
|
### 0.4.17 (2017-09-21)
|
||||||
|
|
||||||
|
@ -198,6 +198,7 @@ bool SemanticInformation::invalidInPureFunctions(Instruction _instruction)
|
|||||||
case Instruction::ORIGIN:
|
case Instruction::ORIGIN:
|
||||||
case Instruction::CALLER:
|
case Instruction::CALLER:
|
||||||
case Instruction::CALLVALUE:
|
case Instruction::CALLVALUE:
|
||||||
|
case Instruction::GAS:
|
||||||
case Instruction::GASPRICE:
|
case Instruction::GASPRICE:
|
||||||
case Instruction::EXTCODESIZE:
|
case Instruction::EXTCODESIZE:
|
||||||
case Instruction::EXTCODECOPY:
|
case Instruction::EXTCODECOPY:
|
||||||
@ -223,7 +224,6 @@ bool SemanticInformation::invalidInViewFunctions(Instruction _instruction)
|
|||||||
case Instruction::SSTORE:
|
case Instruction::SSTORE:
|
||||||
case Instruction::JUMP:
|
case Instruction::JUMP:
|
||||||
case Instruction::JUMPI:
|
case Instruction::JUMPI:
|
||||||
case Instruction::GAS:
|
|
||||||
case Instruction::LOG0:
|
case Instruction::LOG0:
|
||||||
case Instruction::LOG1:
|
case Instruction::LOG1:
|
||||||
case Instruction::LOG2:
|
case Instruction::LOG2:
|
||||||
|
@ -349,7 +349,7 @@ BOOST_AUTO_TEST_CASE(assembly)
|
|||||||
assembly { x := 7 }
|
assembly { x := 7 }
|
||||||
}
|
}
|
||||||
function g() view public {
|
function g() view public {
|
||||||
assembly { for {} 1 { pop(sload(0)) } { } }
|
assembly { for {} 1 { pop(sload(0)) } { } pop(gas) }
|
||||||
}
|
}
|
||||||
function h() view public {
|
function h() view public {
|
||||||
assembly { function g() { pop(blockhash(20)) } }
|
assembly { function g() { pop(blockhash(20)) } }
|
||||||
@ -357,6 +357,9 @@ BOOST_AUTO_TEST_CASE(assembly)
|
|||||||
function j() public {
|
function j() public {
|
||||||
assembly { pop(call(0, 1, 2, 3, 4, 5, 6)) }
|
assembly { pop(call(0, 1, 2, 3, 4, 5, 6)) }
|
||||||
}
|
}
|
||||||
|
function k() public {
|
||||||
|
assembly { pop(call(gas, 1, 2, 3, 4, 5, 6)) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
CHECK_SUCCESS_NO_WARNINGS(text);
|
CHECK_SUCCESS_NO_WARNINGS(text);
|
||||||
@ -367,7 +370,7 @@ BOOST_AUTO_TEST_CASE(assembly_staticcall)
|
|||||||
string text = R"(
|
string text = R"(
|
||||||
contract C {
|
contract C {
|
||||||
function i() view public {
|
function i() view public {
|
||||||
assembly { pop(staticcall(0, 1, 2, 3, 4, 5)) }
|
assembly { pop(staticcall(gas, 1, 2, 3, 4, 5)) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
|
Loading…
Reference in New Issue
Block a user