argotorg / argotorg/solidity

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

Open
#13,840 2 comments 1 reaction 0 assignees View on GitHub
low impact medium effort must have eventually needs design
Dominant language
C++
Stars
25.7k
Forks
6.2k
Avg merge
2d 19h
Merged PRs (30d)
29

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.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the Solidity constructor example and checking the compiler's current diagnostics for the `owner == msg.sender` expression. Clarify how the requested warning applies to `view` expressions, then consider the issue done when the compiler emits the intended warning for the relevant no-effect expression without incorrectly rejecting valid code.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, solidity
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.