Skip to content

Commit 691083c

Browse files
authored
Merge pull request #11632 from ethereum/yulNegationFunctionNameCollision
Fix negation function name collision.
2 parents 9abaa35 + 0a6fc89 commit 691083c

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

libsolidity/codegen/YulUtilFunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4029,7 +4029,7 @@ string YulUtilFunctions::negateNumberWrappingFunction(Type const& _type)
40294029
IntegerType const& type = dynamic_cast<IntegerType const&>(_type);
40304030
solAssert(type.isSigned(), "Expected signed type!");
40314031

4032-
string const functionName = "negate_" + _type.identifier();
4032+
string const functionName = "negate_wrapping_" + _type.identifier();
40334033
return m_functionCollector.createFunction(functionName, [&]() {
40344034
return Whiskers(R"(
40354035
function <functionName>(value) -> ret {

test/libsolidity/semanticTests/externalContracts/prbmath_signed.sol

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ contract test {
5050
// compileViaYul: also
5151
// ----
5252
// constructor()
53-
// gas irOptimized: 1947094
53+
// gas irOptimized: 1965559
5454
// gas legacy: 2602700
5555
// gas legacyOptimized: 1874490
5656
// div(int256,int256): 3141592653589793238, 88714123 -> 35412542528203691288251815328
57-
// gas irOptimized: 22222
57+
// gas irOptimized: 22244
5858
// gas legacy: 22767
5959
// gas legacyOptimized: 22282
6060
// exp(int256): 3141592653589793238 -> 23140692632779268978
@@ -82,7 +82,7 @@ contract test {
8282
// gas legacy: 22807
8383
// gas legacyOptimized: 22295
8484
// pow(int256,uint256): 3141592653589793238, 5 -> 306019684785281453040
85-
// gas irOptimized: 22863
85+
// gas irOptimized: 22861
8686
// gas legacy: 23508
8787
// gas legacyOptimized: 22921
8888
// sqrt(int256): 3141592653589793238 -> 1772453850905516027
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
contract C {
2+
function f() public pure {
3+
-(int8(0));
4+
unchecked {
5+
// Used to incorrectly use the checked unary negation function and revert.
6+
(-(type(int8).min));
7+
}
8+
}
9+
}
10+
// ====
11+
// compileViaYul: also
12+
// ----
13+
// f() ->

0 commit comments

Comments
 (0)