Merge pull request #12553 from ethereum/ir-ice-12546

Fix .push() not considering external functions
This commit is contained in:
Daniel Kirchner 2022-01-19 13:41:20 +01:00 committed by GitHub
commit 92c262d116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 30 additions and 1 deletions

View File

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

View File

@ -3609,7 +3609,7 @@ string YulUtilFunctions::copyStructToStorageFunction(StructType const& _from, St
auto const& [srcSlotOffset, srcOffset] = _from.storageOffsetsOfMember(structMembers[i].name);
t("memberOffset", formatNumber(srcSlotOffset));
if (memberType.isValueType())
t("read", readFromStorageValueType(memberType, srcOffset, false));
t("read", readFromStorageValueType(memberType, srcOffset, true));
else
solAssert(srcOffset == 0, "");

View File

@ -0,0 +1,28 @@
contract C {
struct Struct {
function () external el;
}
Struct[] array;
int externalCalled = 0;
function ext() external {
externalCalled++;
}
function f() public {
array.push(Struct(this.ext));
array.push(array[0]);
array[0].el();
array[1].el();
assert(externalCalled == 2);
}
}
// ====
// compileViaYul: also
// ----
// f() ->
// gas irOptimized: 113142
// gas legacy: 112937
// gas legacyOptimized: 112608