From 59da25056becdc46d9c004dd6b4f50ce78d6f2a0 Mon Sep 17 00:00:00 2001 From: chriseth Date: Wed, 11 Nov 2020 17:38:56 +0100 Subject: [PATCH] Fix Yul codegen for try with create. --- libsolidity/codegen/ir/IRGeneratorForStatements.cpp | 13 ++++++++++--- .../immutable/getter_call_in_constructor.sol | 1 + .../semanticTests/salted_create/salted_create.sol | 1 + test/libsolidity/semanticTests/tryCatch/create.sol | 1 + 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index a24e3c0dd..e218da375 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -1365,10 +1365,13 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) datacopy(, dataoffset(""), datasize("")) := () - let := create2(, , sub(, ), ) + let
:= create2(, , sub(, ), ) - let := create(, , sub(, )) + let
:= create(, , sub(, )) + + let := iszero(iszero(
)) + () )"); t("memPos", m_context.newYulVariable()); @@ -1385,7 +1388,11 @@ void IRGeneratorForStatements::endVisit(FunctionCall const& _functionCall) t("saltSet", functionType->saltSet()); if (functionType->saltSet()) t("salt", IRVariable(_functionCall.expression()).part("salt").name()); - t("retVars", IRVariable(_functionCall).commaSeparatedList()); + solAssert(IRVariable(_functionCall).stackSlots().size() == 1, ""); + t("address", IRVariable(_functionCall).commaSeparatedList()); + t("isTryCall", _functionCall.annotation().tryCall); + if (_functionCall.annotation().tryCall) + t("success", IRNames::trySuccessConditionVariable(_functionCall)); m_code << t.render(); break; diff --git a/test/libsolidity/semanticTests/immutable/getter_call_in_constructor.sol b/test/libsolidity/semanticTests/immutable/getter_call_in_constructor.sol index 2ef12c04a..fd2300d43 100644 --- a/test/libsolidity/semanticTests/immutable/getter_call_in_constructor.sol +++ b/test/libsolidity/semanticTests/immutable/getter_call_in_constructor.sol @@ -12,6 +12,7 @@ contract C { } } // ==== +// compileViaYul: also // EVMVersion: >=tangerineWhistle // ---- // f() -> true diff --git a/test/libsolidity/semanticTests/salted_create/salted_create.sol b/test/libsolidity/semanticTests/salted_create/salted_create.sol index b20adf74b..6a08fb18a 100644 --- a/test/libsolidity/semanticTests/salted_create/salted_create.sol +++ b/test/libsolidity/semanticTests/salted_create/salted_create.sol @@ -17,6 +17,7 @@ contract A { } } // ==== +// compileViaYul: also // EVMVersion: >=constantinople // ---- // different_salt() -> true diff --git a/test/libsolidity/semanticTests/tryCatch/create.sol b/test/libsolidity/semanticTests/tryCatch/create.sol index ad7f734c7..7fd776f6d 100644 --- a/test/libsolidity/semanticTests/tryCatch/create.sol +++ b/test/libsolidity/semanticTests/tryCatch/create.sol @@ -26,6 +26,7 @@ contract C { } } // ==== +// compileViaYul: also // EVMVersion: >=byzantium // ---- // f() -> 0, 0, 96, 13, "test message."