``Statement has no effect`` warning should be emitted for ``view`` expressions.
- 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
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