Skip to content

Commit 92c262d

Browse files
authored
Merge pull request #12553 from ethereum/ir-ice-12546
Fix .push() not considering external functions
2 parents ecd8b97 + 89d6bff commit 92c262d

File tree

3 files changed

+30
-1
lines changed

3 files changed

+30
-1
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Bugfixes:
1414
* Antlr Grammar: Allow builtin names in ``yulPath`` to support ``.address`` in function pointers.
1515
* Control Flow Graph: Perform proper virtual lookup for modifiers for uninitialized variable and unreachable code analysis.
1616
* Immutables: Fix wrong error when the constructor of a base contract uses ``return`` and the parent contract contains immutable variables.
17+
* IR Generator: Fix IR syntax error when copying storage arrays of structs containing functions.
1718
* Natspec: Fix ICE when overriding a struct getter with a Natspec-documented return value and the name in the struct is different.
1819
* TypeChecker: Fix ICE when a constant variable declaration forward references a struct.
1920

libsolidity/codegen/YulUtilFunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3609,7 +3609,7 @@ string YulUtilFunctions::copyStructToStorageFunction(StructType const& _from, St
36093609
auto const& [srcSlotOffset, srcOffset] = _from.storageOffsetsOfMember(structMembers[i].name);
36103610
t("memberOffset", formatNumber(srcSlotOffset));
36113611
if (memberType.isValueType())
3612-
t("read", readFromStorageValueType(memberType, srcOffset, false));
3612+
t("read", readFromStorageValueType(memberType, srcOffset, true));
36133613
else
36143614
solAssert(srcOffset == 0, "");
36153615

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
contract C {
2+
struct Struct {
3+
function () external el;
4+
}
5+
Struct[] array;
6+
int externalCalled = 0;
7+
8+
function ext() external {
9+
externalCalled++;
10+
}
11+
12+
function f() public {
13+
array.push(Struct(this.ext));
14+
array.push(array[0]);
15+
16+
array[0].el();
17+
array[1].el();
18+
19+
assert(externalCalled == 2);
20+
}
21+
}
22+
// ====
23+
// compileViaYul: also
24+
// ----
25+
// f() ->
26+
// gas irOptimized: 113142
27+
// gas legacy: 112937
28+
// gas legacyOptimized: 112608

0 commit comments

Comments
 (0)