Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suspected false positive: operator assignment inside loop #28

Closed
mmcloughlin opened this issue Mar 20, 2021 · 1 comment
Closed

Suspected false positive: operator assignment inside loop #28

mmcloughlin opened this issue Mar 20, 2021 · 1 comment

Comments

@mmcloughlin
Copy link

The following code generates an error for the s *= 2 statement:

func (FermatStrategy) K(n *big.Int) []*big.Int {
	ks := []*big.Int{}
	k := new(big.Int).Rsh(n, 1)
	one := bigint.One()
	s := uint(1)
	for k.Cmp(one) > 0 {
		ks = append(ks, bigint.Clone(k))
		k.Rsh(k, s)
		s *= 2
	}
	return ks
}

https://github.com/mmcloughlin/addchain/blob/3d88f7689d76cd7d9afa7cefaac9a0ab6c5ba3c2/alg/contfrac/contfrac.go#L225

Specifically, when run via golangci-lint version 1.38.0 I see:

alg/contfrac/contfrac.go:225:3: reassigned, but never used afterwards (wastedassign)
		s *= 2
		^

I believe this is a false positive.

@sanposhiho
Copy link
Owner

Hi @mmcloughlin.

This issue is solved in v0.2.0.

The version of golangci-lint's wastedassign is now v0.1.3.
And, it is upgraded to the new version in this PR. Please wait for the next golangci-lint release, which will be fixed to use wastedassign v0.2.0.

Thank you for your report. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants