the main problem code snippet is as follows:
pragma solidity ^0.4.22;
contract Auction {
address highestBidder; //
function bid() public payable{
require(msg.value < 0.0001 ether,"0.0001 ether");
if(highestBidder != 0){ //
}
}
}
this contract has no problem compiling and running with truffle , including test, but will report a TypeError error when compiling with solc.
contract/Auction.sol:14:12: TypeError: Operator != not compatible with types address and int_const 0
if(highestBidder != 0){
^----------------^
after searching the Internet, it is found that the default value of all declared variables is 0, so there is no problem with this judgment.
Why does solc report an error?
Update:
I tried to find a solution, at least for now solc did not report wrong. Is to change the judgment to:
if (highestBidder! = address (0)) {