Merge pull request #11632 from ethereum/yulNegationFunctionNameCollision

Fix negation function name collision.
This commit is contained in:
chriseth 2021-07-08 12:20:17 +02:00 committed by GitHub
commit 691083c032
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 4 deletions

View File

@ -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 {

View File

@ -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

View 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() ->