From 0479f7f16c3c85a52b0ae895006f655da5ac76f3 Mon Sep 17 00:00:00 2001 From: chriseth Date: Mon, 6 Mar 2017 14:11:55 +0100 Subject: Test for trying to construct an inconstructible contract before its definition. --- test/libsolidity/SolidityNameAndTypeResolution.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'test/libsolidity') diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index 3b137572..437f2adc 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -5060,6 +5060,24 @@ BOOST_AUTO_TEST_CASE(inconstructible_internal_constructor) CHECK_ERROR(text, TypeError, "Contract with internal constructor cannot be created directly."); } +BOOST_AUTO_TEST_CASE(inconstructible_internal_constructor_inverted) +{ + // Previously, the type information for A was not yet available at the point of + // "new A". + char const* text = R"( + contract B { + A a; + function B() { + a = new A(this); + } + } + contract A { + function A(address a) internal {} + } + )"; + CHECK_ERROR(text, TypeError, "Contract with internal constructor cannot be created directly."); +} + BOOST_AUTO_TEST_CASE(constructible_internal_constructor) { char const* text = R"( -- cgit