diff --git a/Changelog.md b/Changelog.md index 0b3749be9..98a0ca408 100644 --- a/Changelog.md +++ b/Changelog.md @@ -9,6 +9,7 @@ Compiler Features: Bugfixes: + * ABI: Skip ``private`` or ``internal`` constructors. diff --git a/libsolidity/interface/ABI.cpp b/libsolidity/interface/ABI.cpp index 56e2ecbde..c00c2f83c 100644 --- a/libsolidity/interface/ABI.cpp +++ b/libsolidity/interface/ABI.cpp @@ -73,9 +73,10 @@ Json::Value ABI::generate(ContractDefinition const& _contractDef) ); abi.emplace(std::move(method)); } - if (_contractDef.constructor()) + FunctionDefinition const* constructor = _contractDef.constructor(); + if (constructor && constructor->visibility() >= Visibility::Public) { - FunctionType constrType(*_contractDef.constructor()); + FunctionType constrType(*constructor); FunctionType const* externalFunctionType = constrType.interfaceFunctionType(); solAssert(!!externalFunctionType, ""); Json::Value method; diff --git a/test/libsolidity/ABIJson/internal_constructor.sol b/test/libsolidity/ABIJson/internal_constructor.sol new file mode 100644 index 000000000..7f8ea5ed2 --- /dev/null +++ b/test/libsolidity/ABIJson/internal_constructor.sol @@ -0,0 +1,9 @@ +// bug #8712 +contract B { + uint immutable x; + constructor(function() internal returns(uint) fp) internal { + x = fp(); } +} +// ---- +// :B +// []