Comments (7)
Hi, everyone!
Is there any movement about go1.19 release? Actually, i can't reproduce that problem with new version:
main.go
package main
import "fmt"
func wastedassignG[T ~int](hoge T) {
var i int
for {
i = 5
}
fmt.Println(i)
}
func wastedassign(hoge int) {
var i int
for {
i = 5
}
fmt.Println(i)
}
func main() {
}
And it gives me this output:
$ go vet -vettool=`which wastedassign` ./main/...
# <path>/main
main/main.go:8:3: assigned to i, but reassigned without using the value
main/main.go:17:3: assigned to i, but reassigned without using the value
Seems like it was fixed and golangci-lint can reenable wastedassign?
from wastedassign.
Hm, thanks for informing. wait for a new version of SSA.
from wastedassign.
SSA has been updated and it seems to work inside golangci-lint.
from wastedassign.
Thanks
from wastedassign.
in fact, the problem is still here
from wastedassign.
The code of the linter needs to be adapted to manage generics:
func wastedassignG[T ~int](hoge T) {
var i int
for {
hoge = 5 // <- not detected KO
// break
}
println(i)
println(hoge)
return
}
func wastedassign(hoge int) {
var i int
for {
hoge = 5 // <- detected OK
// break
}
println(i)
println(hoge)
return
}
from wastedassign.
go1.19 will come in about 2 weeks, it can be good if you can fix your linter before this release.
from wastedassign.
Related Issues (20)
- 他の変数のStoreに用いられているときは使用されているとみなす HOT 1
- if-elseif文の対応が甘い HOT 3
- 連続ループがあると無限待ちになる気がする
- 関数の引数で取得した物を比較でしか使ってないと"reassigned, but never used afterwards"が出る HOT 2
- 無限に再帰してpanicするケースがある HOT 3
- Type-Switchしている箇所の動作が怪しい気がする HOT 4
- 報告する際に変数名も入れたい
- golangci-lintに対応したい HOT 3
- false-positive: reassign inside an infinite loop and not use after exiting loop HOT 1
- Report with variable name HOT 2
- false-positive: variable dependencies in for loop HOT 1
- False positive in loops HOT 2
- complex c style for loop false positive HOT 1
- Suspected false positive: operator assignment inside loop HOT 1
- False positive with switch and function call HOT 3
- support auto fix
- Ignore variable declaration if it's the zero value HOT 4
- Panic case HOT 5
- Document difference to `ineffassign` linter?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wastedassign.