You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
x/tools/gopls: multiple errors for a single instance of 'no new variables' #67961
% cat x.go
package main
func f() (x, y, z int) {
x, y := 1, 2
return
}
% gopls check x.go
Log: Loading packages...
Info: Finished loading packages.
Log: Running...
Info: completed
/Users/rsc/src/rsc.io/gaby/x.go:4:2-14: no new variables on left side of :=
/Users/rsc/src/rsc.io/gaby/x.go:4:7: no new variables on left side of :=
%
In this specific case, one is from compiler and the other is from the nonewvars analyzer.
Does "x/tools/gopls/internal/analysis/nonewvars" still offer a value
if "x/tools/internal/typesinternal" does the check? EDIT: I see. Like #65966, the nonewvars analyzer was to offers fix. In the current gopls architecture, fixes and diagnostics should be exactly paired.
[{
"resource": "main.go",
"owner": "_generated_diagnostic_collection_name_#0",
"code": {
"value": "NoNewVar",
"target": {
"$mid": 1,
"path": "/golang.org/x/tools/internal/typesinternal",
"scheme": "https",
"authority": "pkg.go.dev",
"fragment": "NoNewVar"
}
},
"severity": 8,
"message": "no new variables on left side of :=",
"source": "compiler",
...
}]
[{
"resource": "main.go",
"owner": "_generated_diagnostic_collection_name_#0",
"code": {
"value": "default",
"target": {
"$mid": 1,
"path": "/golang.org/x/tools/gopls/internal/analysis/nonewvars",
"scheme": "https",
"authority": "pkg.go.dev"
}
},
"severity": 4,
"message": "no new variables on left side of :=",
"source": "nonewvars",
...
"tags": [
1
]
}]
Activity
gabyhelp commentedon Jun 13, 2024
Similar Issues
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)
findleyr commentedon Jun 13, 2024
Thanks. I believe this is a dupe of #65966, but will confirm.
hyangah commentedon Jun 14, 2024
In this specific case, one is from compiler and the other is from the nonewvars analyzer.
Does "x/tools/gopls/internal/analysis/nonewvars" still offer a value
if "x/tools/internal/typesinternal" does the check? EDIT: I see. Like #65966, the nonewvars analyzer was to offers fix. In the current gopls architecture, fixes and diagnostics should be exactly paired.
findleyr commentedon Jun 14, 2024
Sounds like this is indeed a dupe of #65966. Thanks for confirming, @hyangah!
We need to improve our diagnostic merging logic.