Skip to content

Commit 89d6bff

Browse files
committed
Fix .push() not considering external functions
1 parent a07b3ec commit 89d6bff

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
@@ -13,6 +13,7 @@ Bugfixes:
1313
* Antlr Grammar: Allow builtin names in ``yulPath`` to support ``.address`` in function pointers.
1414
* Control Flow Graph: Perform proper virtual lookup for modifiers for uninitialized variable and unreachable code analysis.
1515
* Immutables: Fix wrong error when the constructor of a base contract uses ``return`` and the parent contract contains immutable variables.
16+
* IR Generator: Fix IR syntax error when copying storage arrays of structs containing functions.
1617
* Natspec: Fix ICE when overriding a struct getter with a Natspec-documented return value and the name in the struct is different.
1718
* TypeChecker: Fix ICE when a constant variable declaration forward references a struct.
1819

libsolidity/codegen/YulUtilFunctions.cpp

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

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)