]> Cypherpunks repositories - gostls13.git/commit
go/types: set correct Var.scopePos for parameters/results
authorAlan Donovan <adonovan@google.com>
Mon, 20 Nov 2023 22:22:37 +0000 (17:22 -0500)
committerGopher Robot <gobot@golang.org>
Thu, 30 Nov 2023 01:15:55 +0000 (01:15 +0000)
commita27a525d1b4df74989ac9f6ad10394391fe3eb88
tree94ca537c9d0a41e3c532622e65eb9b6d9a04d652
parent858cd8da569938913541d013af27a2a2a875fcb5
go/types: set correct Var.scopePos for parameters/results

Previously, its value was unset (NoPos), but the correct
value is a point after the signature (FuncType.End) and
before the body.

Also, fix a bug in Scope.Innermost whereby it would return
the wrong (outer) scope when the query position was in
the FuncType portion of a Func{Decl,Lit}.
The fix is to set the scope's pos/end to those of the
complete Func{Decl,Lit}. This is now documented at
Info.Scopes, along with other missing information.

Also, fix a bug in the go/types (but not types2) scope
test, in which comments were discarded by the parser,
causing the entire test to be a no-op (!).

Also, make failures of TestScopeLookupParent more
informative.

Also, add a release note about the change in behavior.

Fixes #64292
Fixes #64295

Change-Id: Ib681f59d1b0b43de977666db08302d7524d3305f
Reviewed-on: https://go-review.googlesource.com/c/go/+/544035
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Robert Griesemer <gri@google.com>
16 files changed:
doc/go1.22.html
src/cmd/compile/internal/types2/api.go
src/cmd/compile/internal/types2/api_test.go
src/cmd/compile/internal/types2/decl.go
src/cmd/compile/internal/types2/expr.go
src/cmd/compile/internal/types2/signature.go
src/cmd/compile/internal/types2/stmt.go
src/cmd/compile/internal/types2/util_test.go
src/go/types/api.go
src/go/types/api_test.go
src/go/types/decl.go
src/go/types/eval_test.go
src/go/types/expr.go
src/go/types/signature.go
src/go/types/stmt.go
src/go/types/util_test.go