Full source code of the file 'Test.sol' :
pragma solidity ^0.4.23;
contract Mortal{
address owner;
string ownerInfo = "Contract Owner name XYZ";
constructor () public {
owner = msg.sender;
}
function kill () public {
if (msg.sender == owner) {
selfdestruct(owner);
}
}
function ownerInfo() public view returns (string) {
return ownerInfo;
}
}
contract Test is Mortal {
string message = "Hello World!";
constructor () public {
}
function getMessage() public view returns (string){
return message;
}
}
Compiler Error:
myMac:solidity admin$ solc Test.sol
Test.sol:21:2: Error: Identifier already declared.
function ownerInfo() public view returns (string) {
^ (Relevant source part starts here and spans across multiple lines).
Test.sol:9:2: The previous declaration is here:
string ownerInfo = "Contract Owner name XYZ";
^------------------------------------------^
I don't see any duplicate declaration of ownerInfo
. Any idea, why am I getting this error?