mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #11632 from ethereum/yulNegationFunctionNameCollision
Fix negation function name collision.
This commit is contained in:
commit
691083c032
@ -4029,7 +4029,7 @@ string YulUtilFunctions::negateNumberWrappingFunction(Type const& _type)
|
||||
IntegerType const& type = dynamic_cast<IntegerType const&>(_type);
|
||||
solAssert(type.isSigned(), "Expected signed type!");
|
||||
|
||||
string const functionName = "negate_" + _type.identifier();
|
||||
string const functionName = "negate_wrapping_" + _type.identifier();
|
||||
return m_functionCollector.createFunction(functionName, [&]() {
|
||||
return Whiskers(R"(
|
||||
function <functionName>(value) -> ret {
|
||||
|
@ -50,11 +50,11 @@ contract test {
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// constructor()
|
||||
// gas irOptimized: 1947094
|
||||
// gas irOptimized: 1965559
|
||||
// gas legacy: 2602700
|
||||
// gas legacyOptimized: 1874490
|
||||
// div(int256,int256): 3141592653589793238, 88714123 -> 35412542528203691288251815328
|
||||
// gas irOptimized: 22222
|
||||
// gas irOptimized: 22244
|
||||
// gas legacy: 22767
|
||||
// gas legacyOptimized: 22282
|
||||
// exp(int256): 3141592653589793238 -> 23140692632779268978
|
||||
@ -82,7 +82,7 @@ contract test {
|
||||
// gas legacy: 22807
|
||||
// gas legacyOptimized: 22295
|
||||
// pow(int256,uint256): 3141592653589793238, 5 -> 306019684785281453040
|
||||
// gas irOptimized: 22863
|
||||
// gas irOptimized: 22861
|
||||
// gas legacy: 23508
|
||||
// gas legacyOptimized: 22921
|
||||
// sqrt(int256): 3141592653589793238 -> 1772453850905516027
|
||||
|
13
test/libsolidity/semanticTests/viaYul/negation_bug.yul
Normal file
13
test/libsolidity/semanticTests/viaYul/negation_bug.yul
Normal file
@ -0,0 +1,13 @@
|
||||
contract C {
|
||||
function f() public pure {
|
||||
-(int8(0));
|
||||
unchecked {
|
||||
// Used to incorrectly use the checked unary negation function and revert.
|
||||
(-(type(int8).min));
|
||||
}
|
||||
}
|
||||
}
|
||||
// ====
|
||||
// compileViaYul: also
|
||||
// ----
|
||||
// f() ->
|
Loading…
Reference in New Issue
Block a user