]> Cypherpunks.ru repositories - gostls13.git/commit
[release-branch.go1.20] cmd/compile/internal/noder: correct positions for synthetic...
authorMatthew Dempsky <mdempsky@google.com>
Tue, 14 Feb 2023 23:13:50 +0000 (15:13 -0800)
committerGopher Robot <gobot@golang.org>
Tue, 28 Feb 2023 00:07:00 +0000 (00:07 +0000)
commit0f4483cfdcf303ac5cbe4f4536e23750423137d9
tree7005494a6e945aa6b95825befd5ede2f86b856e6
parent1362737f50ad2cb827eb1b8bc93d8d78e45a1371
[release-branch.go1.20] cmd/compile/internal/noder: correct positions for synthetic closures

When inlining functions that contain function literals, we need to be
careful about position information. The OCLOSURE node should use the
inline-adjusted position, but the ODCLFUNC and its body should use the
original positions.

However, the same problem can arise with certain generic constructs,
which require the compiler to synthesize function literals to insert
dictionary arguments.

go.dev/cl/425395 fixed the issue with user-written function literals
in a somewhat kludgy way; this CL extends the same solution to
synthetic function literals.

This is all quite subtle and the solutions aren't terribly robust, so
longer term it's probably desirable to revisit how we track inlining
context for positions. But for now, this seems to be the least bad
solution, esp. for backporting to 1.20.

Updates #54625.
Fixes #58531.

Change-Id: Icc43a70dbb11a0e665cbc9e6a64ef274ad8253d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/468415
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
(cherry picked from commit 873c14cec730ee278848f7cc58d2b4d89ab52288)
Reviewed-on: https://go-review.googlesource.com/c/go/+/471677
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
src/cmd/compile/internal/noder/reader.go
test/typeparam/issue58513.go [new file with mode: 0644]