From 0ede2d2df324b8044b6eea97430dae3a778e90d8 Mon Sep 17 00:00:00 2001 From: chriseth Date: Tue, 2 Feb 2021 11:41:43 +0100 Subject: [PATCH] fixup! Code generation for errors. --- .../codegen/ir/IRGeneratorForStatements.cpp | 1 + .../semanticTests/errors/via_import.sol | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 test/libsolidity/semanticTests/errors/via_import.sol diff --git a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp index 72a73f11c..b397af546 100644 --- a/libsolidity/codegen/ir/IRGeneratorForStatements.cpp +++ b/libsolidity/codegen/ir/IRGeneratorForStatements.cpp @@ -1977,6 +1977,7 @@ void IRGeneratorForStatements::endVisit(MemberAccess const& _memberAccess) solAssert( dynamic_cast(_memberAccess.annotation().referencedDeclaration) || dynamic_cast(_memberAccess.annotation().referencedDeclaration) || + dynamic_cast(_memberAccess.annotation().referencedDeclaration) || category == Type::Category::TypeType || category == Type::Category::Module, "" diff --git a/test/libsolidity/semanticTests/errors/via_import.sol b/test/libsolidity/semanticTests/errors/via_import.sol new file mode 100644 index 000000000..b36160e0a --- /dev/null +++ b/test/libsolidity/semanticTests/errors/via_import.sol @@ -0,0 +1,37 @@ +==== Source: s1.sol ==== +error E(uint); +==== Source: s2.sol ==== +import "s1.sol" as S; +==== Source: s3.sol ==== +import "s1.sol" as S; +import "s2.sol" as T; +import "s1.sol"; +contract C { + function a() public pure { + require(false, E(1)); + } + function b() public pure { + require(false, S.E(2)); + } + function c() public pure { + require(false, T.S.E(3)); + } + function x() public pure { + revert(E(1)); + } + function y() public pure { + revert(S.E(2)); + } + function z() public pure { + revert(T.S.E(3)); + } +} +// ==== +// compileViaYul: also +// ---- +// a() -> FAILURE, hex"002ff067", hex"0000000000000000000000000000000000000000000000000000000000000001" +// b() -> FAILURE, hex"002ff067", hex"0000000000000000000000000000000000000000000000000000000000000002" +// c() -> FAILURE, hex"002ff067", hex"0000000000000000000000000000000000000000000000000000000000000003" +// x() -> FAILURE, hex"002ff067", hex"0000000000000000000000000000000000000000000000000000000000000001" +// y() -> FAILURE, hex"002ff067", hex"0000000000000000000000000000000000000000000000000000000000000002" +// z() -> FAILURE, hex"002ff067", hex"0000000000000000000000000000000000000000000000000000000000000003"