solidity/test/libsolidity/syntaxTests/constructor/constructor_visibility.sol

14 lines
539 B
Solidity
Raw Normal View History

2018-04-17 09:39:40 +00:00
// The constructor of a base class should not be visible in the derived class
2020-06-23 12:14:24 +00:00
contract A { constructor(string memory) { } }
2018-04-17 09:39:40 +00:00
contract B is A {
function f() pure public {
A x = A(address(0)); // convert from address
2018-04-17 09:39:40 +00:00
string memory y = "ab";
A(y); // call as a function is invalid
x;
}
}
// ----
// TypeError 3415: (124-303): No arguments passed to the base constructor. Specify the arguments or mark "B" as abstract.
// TypeError 9640: (252-256): Explicit type conversion not allowed from "string memory" to "contract A".