Skip to content

Statement has no effect warning should be emitted for view expressions. #13840

Open
@0xrisec

Description

@0xrisec
// 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    low impactChanges are not very noticeable or potential benefits are limited.medium effortDefault level of effortmust have eventuallySomething we consider essential but not enough to prevent us from releasing Solidity 1.0 without it.needs designThe proposal is too vague to be implemented right away

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions