From 7653e6d3d5edc0ac8e4a3d0c9d9cdbf718618855 Mon Sep 17 00:00:00 2001 From: Edward Muller Date: Fri, 14 Jun 2019 20:32:31 +0000 Subject: [PATCH] internal/lsp/cache: fix ineffectual err assignment The `if err :=` block creates a shadow err value that is then discarded after the block. Change-Id: I78f6a7298ac5d3d86ece056a9e328bcee9fdc683 Change-Id: I78f6a7298ac5d3d86ece056a9e328bcee9fdc683 GitHub-Last-Rev: 4bac8fb982fa3a0724206422b1a4dbc5e41c34a9 GitHub-Pull-Request: golang/tools#114 Reviewed-on: https://go-review.googlesource.com/c/tools/+/181777 Run-TryBot: Rebecca Stambler TryBot-Result: Gobot Gobot Reviewed-by: Ian Cottrell --- internal/lsp/cache/parse.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/internal/lsp/cache/parse.go b/internal/lsp/cache/parse.go index fe7c4dd6a1..3f7f868843 100644 --- a/internal/lsp/cache/parse.go +++ b/internal/lsp/cache/parse.go @@ -232,7 +232,8 @@ func fix(ctx context.Context, file *ast.File, tok *token.File, src []byte) error } switch n := n.(type) { case *ast.BadStmt: - if err := parseDeferOrGoStmt(n, parent, tok, src); err != nil { + err = parseDeferOrGoStmt(n, parent, tok, src) // don't shadow err + if err != nil { err = fmt.Errorf("unable to parse defer or go from *ast.BadStmt: %v", err) } return false