Open
Description
// SPDX-License-Identifier: GPL-3.0
pragma solidity 0.8.17;
contract Lottery{
address public owner;
constructor(){
owner == msg.sender;
}
}
Issue: In the given code, there is a mistake in the assignment of the owner
variable in the constructor
function. Instead of using the assignment operator =
, the double equal ==
operator is used, which is a comparison operator and does not assign a value to the variable. This mistake can be hard to identify, as the Solidity compiler does not raise any warnings
or errors
for this issue.
Feature Expected: As a result, it is essential for the compiler should carefully check the code and make sure that the correct operators are used at the time of initialization of a variable at the function level.