summaryrefslogtreecommitdiff
path: root/src/go
Commit message (Collapse)AuthorAgeFilesLines
* [dev.unified] all: merge master (85d87b9) into dev.unifieddev.unifiedMatthew Dempsky2022-08-041-218/+15
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge List: + 2022-08-04 85d87b9c75 all: update vendored golang.org/x dependencies for Go 1.20 development + 2022-08-04 fb1bfd4d37 all: remove pre-Go 1.17 workarounds + 2022-08-04 44ff9bff0c runtime: clean up panic and deadlock lock ranks + 2022-08-04 f42dc0de74 runtime: make the lock rank DAG make more sense + 2022-08-04 d29a0282e9 runtime: add mayAcquire annotation for finlock + 2022-08-04 c5be4ed7df runtime: add missing trace lock edges + 2022-08-04 2b8a9a484f runtime: generate the lock ranking from a DAG description + 2022-08-04 ddfd639408 runtime: delete unused lock ranks + 2022-08-04 426ea5702b internal/dag: add a Graph type and make node order deterministic + 2022-08-04 d37cc9a8cd go/build, internal/dag: lift DAG parser into an internal package + 2022-08-04 ab0a94c6d3 cmd/dist: require Go 1.17 for building Go + 2022-08-04 1e3c19f3fe runtime: support riscv64 SV57 mode + 2022-08-03 f28fa952b5 make.bat, make.rc: show bootstrap toolchain version + 2022-08-03 87384801dc cmd/asm: update package doc to describe "-p" option + 2022-08-03 c6a2dada0d net: disable TestIPv6WriteMsgUDPAddrPortTargetAddrIPVersion [sic] on DragonflyBSD + 2022-08-02 29b9a328d2 runtime: trivial replacements of g in remaining files + 2022-08-02 c647264619 runtime: trivial replacements of g in signal_unix.go + 2022-08-02 399f50c9d7 runtime: tricky replacements of g in traceback.go + 2022-08-02 4509e951ec runtime: tricky replacements of g in proc.go + 2022-08-02 4400238ec8 runtime: trivial replacements of _g_ in remaining files + 2022-08-02 5999a28de8 runtime: trivial replacements of _g_ in os files + 2022-08-02 0e18cf6d09 runtime: trivial replacements of _g_ in GC files + 2022-08-02 4358a53a97 runtime: trivial replacements of _g_ in proc.go + 2022-08-02 b486518964 runtime: tricky replacements of _g_ in os3_solaris.go + 2022-08-02 54a0ab3f7b runtime: tricky replacements of _g_ in os3_plan9.go + 2022-08-02 4240ff764b runtime: tricky replacements of _g_ in signal_windows.go + 2022-08-02 8666d89ca8 runtime: tricky replacements of _g_ in signal_unix.go + 2022-08-02 74cee276fe runtime: tricky replacements of _g_ in trace.go + 2022-08-02 222799fde6 runtime: tricky replacements of _g_ in mgc.go + 2022-08-02 e9d7f54a1a runtime: tricky replacements of _g_ in proc.go + 2022-08-02 5e8d261918 runtime: rename _p_ to pp + 2022-08-02 0ad2ec6596 runtime: clean up dopanic_m + 2022-08-02 7e952962df runtime: clean up canpanic + 2022-08-02 9dbc0f3556 runtime: fix outdated g.m comment in traceback.go + 2022-08-02 d723df76da internal/goversion: update Version to 1.20 + 2022-08-02 1b7e71e8ae all: disable tests that fail on Alpine + 2022-08-01 f2a9f3e2e0 test: improve generic type assertion test + 2022-08-01 27038b70f8 cmd/compile: fix wrong dict pass condition for type assertions + 2022-08-01 e99f53fed9 doc: move Go 1.19 release notes to x/website + 2022-08-01 8b13a073a1 doc: mention removal of cmd/compile's -importmap and -installsuffix flags + 2022-08-01 e95fd4c238 doc/go1.19: fix typo: EM_LONGARCH -> EM_LOONGARCH + 2022-08-01 dee3efd9f8 doc/go1.19: fix a few links that were missing trailing slashes + 2022-07-30 f32519e5fb runtime: fix typos + 2022-07-29 9a2001a8cc cmd/dist: always pass -short=true with -quick + 2022-07-28 5c8ec89cb5 doc/go1.19: minor adjustments and links + 2022-07-28 417be37048 doc/go1.19: improve the loong64 release notes + 2022-07-28 027855e8d8 os/exec: add GODEBUG setting to opt out of ErrDot changes Change-Id: Idc0fbe93978c0dff7600b90a2c3ecc067fd9f5f2
| * internal/dag: add a Graph type and make node order deterministicAustin Clements2022-08-041-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The go/types package doesn't care about node ordering because it's just querying paths in the graph, but we're about to use this for the runtime lock graph, and there we want determinism. For #53789. Change-Id: Ic41329bf2eb9a3a202f97c21c761ea588ca551c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/418593 Reviewed-by: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Austin Clements <austin@google.com>
| * go/build, internal/dag: lift DAG parser into an internal packageAustin Clements2022-08-041-212/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This lifts the DAG parser from the go/build dependencies test into its own package that can be reused elsewhere. I tried to keep the code as close as possible. I changed some names to reflect the more general purpose of internal/dag. Most of the changes are related to error handling, since internal/dag doesn't take a testing.T on which to report errors. Notably, parseRules now returns a slice of parsed rules rather than calling a callback because this made it easier to separate fatal parsing errors from non-fatal graph checking errors. For #53789. Change-Id: I170b84fd85f971cfc1a50972156d48e78b45fce3 Reviewed-on: https://go-review.googlesource.com/c/go/+/418592 Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
| * os/exec: add GODEBUG setting to opt out of ErrDot changesRuss Cox2022-07-281-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The changes are likely to break users, and we need to make it easy to unbreak without code changes. For #43724. Fixes #53962. Change-Id: I105c5d6c801d354467e0cefd268189c18846858e Reviewed-on: https://go-review.googlesource.com/c/go/+/419794 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
* | [dev.unified] go/internal: set underlying types in proper orderDavid Chase2022-07-303-1/+67
| | | | | | | | | | | | | | | | | | | | | | | | This problem appeared in google-internal testing. If the run-later functions are run in the wrong order, type definitions won't resolve properly. Change-Id: I9da0775976282e92ca036d20fd9fd6650900daf9 Reviewed-on: https://go-review.googlesource.com/c/go/+/419996 Run-TryBot: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
* | [dev.unified] go/internal/gcimporter: flatten importsMatthew Dempsky2022-07-281-1/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current documentation for go/types.(*Packages).Imports requires that the import graph be flattened when read from export data. I think this is a documentation bug (incorrectly codifying the existing behavior, rather than documenting it as a known bug), but until that's decided, we can at least flatten imports ourselves. Updates #54096. Change-Id: Idc054a2efc908b3e6651e6567d0ea0e89bb0c54d Reviewed-on: https://go-review.googlesource.com/c/go/+/419596 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* | [dev.unified] cmd/compile: move "has init" to private metadataMatthew Dempsky2022-07-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, there's a "has init" bool in the public metadata section, which is only needed by cmd/compile; but because it's in the public metadata section, it's known to the go/types importers too. This CL moves it instead to the new compiler-only private metadata section added in the last CL for the inline bodies index. The existing bool in the public metadata section is left in place, and just always set to false, to avoid breaking the x/tools importer. The next time we bump the export version number, we can remove the bool properly. But no urgency just yet. Change-Id: I380f358652374b5a221f85020a53dc65912ddb29 Reviewed-on: https://go-review.googlesource.com/c/go/+/419676 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* | [dev.unified] all: merge master (8e1e64c) into dev.unifiedDavid Chase2022-07-1916-30/+445
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: - test/run.go Conflicts in the known-fails list, plus removed a test from the known-fails that now works. Merge List: + 2022-07-19 8e1e64c16a cmd/compile: fix mknode script + 2022-07-19 28be440d34 A+C: add Weizhi Yan + 2022-07-19 85a482fc24 runtime: revert to using the precomputed trigger for pacer calculations + 2022-07-19 ae7340ab68 CONTRIBUTORS: update for the Go 1.19 release + 2022-07-18 de8101d21b runtime: fix typos + 2022-07-18 967a3d985d cmd/compile: revert "remove -installsuffix flag" + 2022-07-18 c0c1bbde17 http: improve Get documentation + 2022-07-15 2aa473cc54 go/types, types2: correct alignment of atomic.Int64 + 2022-07-15 4651ebf961 encoding/gob: s/TestIngoreDepthLimit/TestIgnoreDepthLimit/ + 2022-07-14 dc00aed6de go/parser: skip TestParseDepthLimit for short tests + 2022-07-14 783ff7dfc4 encoding/xml: skip TestCVE202230633 for short tests + 2022-07-14 aa80228526 cmd/go/internal/modfetch: avoid duplicating path components in Git fetch errors + 2022-07-14 b9d5a25442 cmd/go: save zip sums for downloaded modules in 'go mod download' in a workspace + 2022-07-14 a906d3dd09 cmd/go: avoid re-enqueuing workspace dependencies with errors + 2022-07-14 266c70c263 doc/go1.19: add a release note for 'go list -json=SomeField' + 2022-07-13 558785a0a9 cmd/compile: remove -installsuffix flag + 2022-07-13 1355ea3045 cmd/compile: remove -importmap flag + 2022-07-13 f71f3d1b86 misc/cgo/testshared: run tests only in GOPATH mode + 2022-07-13 feada53661 misc/cgo/testcshared: don't rely on an erroneous install target in tests + 2022-07-13 c006b7ac27 runtime: clear timerModifiedEarliest when last timer is deleted + 2022-07-13 923740a8cc cmd/compile: fix type assert in dict pass + 2022-07-12 bf2ef26be3 cmd/go: in script tests, avoid checking non-main packages for staleness + 2022-07-12 5f5cae7200 cmd/go: avoid indexing GOROOT packages when the compiler is 'gccgo' + 2022-07-12 c2edb2c841 cmd/go: port TestIssue16471 to a script test and add verbose logging + 2022-07-12 9c2526e637 cmd/go/internal/modfetch/codehost: add missing newline in '# lock' log message + 2022-07-12 85486bcccb image/jpeg: increase TestLargeImageWithShortData timeout by an order of magnitude + 2022-07-12 27794c4d4a cmd/go/internal/modload: ignore disallowed errors when checking for updates + 2022-07-12 b2b8872c87 compress/gzip: fix stack exhaustion bug in Reader.Read + 2022-07-12 ac68c6c683 path/filepath: fix stack exhaustion in Glob + 2022-07-12 fa2d41d0ca io/fs: fix stack exhaustion in Glob + 2022-07-12 6fa37e98ea encoding/gob: add a depth limit for ignored fields + 2022-07-12 695be961d5 go/parser: limit recursion depth + 2022-07-12 08c46ed43d encoding/xml: use iterative Skip, rather than recursive + 2022-07-12 c4c1993fd2 encoding/xml: limit depth of nesting in unmarshal + 2022-07-12 913d05133c cmd/go: avoid spurious readdir during fsys.Walk + 2022-07-12 d3d7998756 net/http: clarify that MaxBytesReader returns *MaxBytesError + 2022-07-11 126c22a098 syscall: gofmt after CL 412114 + 2022-07-11 123a6328b7 internal/trace: don't report regions on system goroutines + 2022-07-11 846490110a runtime/race: update amd64 syso images to avoid sse4 + 2022-07-11 b75ad09cae cmd/trace: fix typo in web documentation + 2022-07-11 7510e597de cmd/go: make module index loading O(1) + 2022-07-11 b8bf820d5d cmd/nm: don't rely on an erroneous install target in tests + 2022-07-11 ad641e8521 misc/cgo/testcarchive: don't rely on an erroneous install target in tests + 2022-07-11 bf5898ef53 net/url: use EscapedPath for url.JoinPath + 2022-07-11 398dcd1cf0 database/sql: make TestTxContextWaitNoDiscard test more robust + 2022-07-11 f956941b0f cmd/go: use package index for std in load.loadPackageData + 2022-07-11 59ab6f351a net/http: remove Content-Encoding in writeNotModified + 2022-07-08 c1a4e0fe01 cmd/compile: fix libfuzzer instrumentation line number + 2022-07-08 5c1a13e7a4 cmd/go: avoid setting variables for '/' and ':' in TestScript subprocess environments + 2022-07-08 180bcad33d net/http: wait for listeners to exit in Server.Close and Shutdown + 2022-07-08 14abe8aa73 cmd/compile: don't convert to interface{} for un-comparable types in generic switch + 2022-07-07 1ebc983000 runtime: overestimate the amount of allocated memory in heapLive + 2022-07-07 c177d9d98a crypto/x509: restrict CRL number to <=20 octets + 2022-07-07 486fc01770 crypto/x509: correctly parse CRL entry extensions + 2022-07-07 8ac58de185 crypto/x509: populate Number and AKI of parsed CRLs + 2022-07-07 0c7fcf6bd1 cmd/link: explicitly disable PIE for windows/amd64 -race mode + 2022-07-07 eaf2125654 cmd/go: default to "exe" build mode for windows -race + 2022-07-06 1243ec9c17 cmd/compile: only check implicit dots for method call enabled by a type bound + 2022-07-06 c391156f96 cmd/go: set up git identity for build_buildvcs_auto.txt + 2022-07-06 2acd3646fc cmd/compile: rework induction variable detector + 2022-07-06 53a4152d47 os/exec: clarify that Wait must be called + 2022-07-06 177306f630 cmd/internal/notsha256: add purego tag as needed + 2022-07-06 f4755fc733 cmd/dist: use purego tag when building the bootstrap binaries + 2022-07-06 4484c30f78 misc/cgo/test: make TestSetgidStress cheaper + 2022-07-06 2007599dc8 test: recognize new gofrontend error message + 2022-07-05 d602380f58 cmd/compile: drop "buildcfg" from no instrument packages + 2022-07-05 c111091071 cmd/go: make module@nonexistentversion failures reusable + 2022-07-05 5f305ae8e5 cmd/go: add -reuse flag to make proxy invocations more efficient + 2022-07-05 84e091eef0 cmd/go: record origin metadata during module download + 2022-07-04 ceda93ed67 build/constraint: update doc to mention a feature added in Go 1.17 + 2022-07-04 3cf79d9610 runtime: pass correct string to exits on Plan 9 + 2022-07-01 e822b1e26e net/http: omit invalid header value from error message + 2022-07-01 4a2a3bca18 cmd/go, go/build: clarify build constraint docs + 2022-07-01 9a4d5357f4 flag: highlight support for double dashes in docs + 2022-07-01 c847a2c9f0 go/types, types2: document that exported predicates are unspecified for invalid type arguments + 2022-06-30 405c269b85 go/types, types2: re-enable a couple of commented out tests + 2022-06-30 aad9382e59 go/doc/comment: support links in lists in comments + 2022-06-30 af725f4286 os: fix a typo in path_windows.go Change-Id: I381728322188aca0bfa81a946d6aedda8c07903c
| * go/types, types2: correct alignment of atomic.Int64Austin Clements2022-07-152-1/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | atomic.Int64 has special logic in the compiler to ensure it's 8-byte aligned on 32-bit architectures. The equivalent logic is missing in go/types, which means the compiler and go/types can come to different conclusions about the layout of types. Fix this by mirroring the compiler's logic into go/types. Fixes #53884. Change-Id: I3f58a56babb76634839a161ca174c8f085fe3ba4 Reviewed-on: https://go-review.googlesource.com/c/go/+/417555 Reviewed-by: Robert Findley <rfindley@google.com>
| * go/parser: skip TestParseDepthLimit for short testsRoland Shoemaker2022-07-141-6/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Because it requires a not insignificant amount of memory to run. Also remove the WASM-only skip from TestScopeDepthLimit, which is less intensive. Fixes #53816 Change-Id: I8463046510ce4dd3d8f6d66938828d5e6963c3be Reviewed-on: https://go-review.googlesource.com/c/go/+/417657 Auto-Submit: Roland Shoemaker <roland@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org>
| * cmd/go: avoid indexing GOROOT packages when the compiler is 'gccgo'Bryan C. Mills2022-07-121-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The gccgo compiler does not load standard-library packages from GOROOT/src, so we cannot load those packages from the GOROOT/src index when using that compiler. This fixes TestScript/gccgo_link_c (and perhaps other gccgo tests) when a 'gccgo' executable is present. Unfortunately, only a few builders caught the broken test because 'gccgo' is not installed on most Go project builders (see #35786). For #53577. Fixes #53815. Change-Id: I11a5cf6dbf4ac9893c4d02bd6ab7ef60f67b1e87 Reviewed-on: https://go-review.googlesource.com/c/go/+/417094 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org>
| * go/parser: limit recursion depthRoland Shoemaker2022-07-124-8/+234
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Limit nested parsing to 100,000, which prevents stack exhaustion when parsing deeply nested statements, types, and expressions. Also limit the scope depth to 1,000 during object resolution. Thanks to Juho Nurminen of Mattermost for reporting this issue. Fixes #53616 Fixes CVE-2022-1962 Change-Id: I4d7b86c1d75d0bf3c7af1fdea91582aa74272c64 Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1491025 Reviewed-by: Russ Cox <rsc@google.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/417063 Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
| * build/constraint: update doc to mention a feature added in Go 1.17Cristian Greco2022-07-041-3/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The pkg documentation mentions that the "//go:build" syntax "will be" added in Go 1.17. In fact, it has been added in that Go release, so the documentation can now be updated. Change-Id: I72f24063c3be62d97ca78bf724d56599f5f19460 GitHub-Last-Rev: 4371886f6ce9f2c2a370df047a5baa1f122c681f GitHub-Pull-Request: golang/go#53647 Reviewed-on: https://go-review.googlesource.com/c/go/+/415774 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
| * cmd/go, go/build: clarify build constraint docsIan Lance Taylor2022-07-011-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clarify that the //go:build line is an expression of constraints, not a constraint itself. Fixes #53308 Change-Id: Ib67243c6ee5cfe3b688c12b943b5e7496f686035 Reviewed-on: https://go-review.googlesource.com/c/go/+/411697 Reviewed-by: Rob Pike <r@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: David Chase <drchase@google.com>
| * go/types, types2: document that exported predicates are unspecified for ↵Robert Griesemer2022-07-011-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | invalid type arguments Per discussion on the issue. For #53595. Change-Id: Iefd161e5c7e792d454652cbe831a0c2d769f748e Reviewed-on: https://go-review.googlesource.com/c/go/+/415574 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
| * go/types, types2: re-enable a couple of commented out testsRobert Griesemer2022-06-301-8/+5
| | | | | | | | | | | | | | | | | | | | Change-Id: Ibb27012b18fc0f0f9f9ef74cc120e7ef981e6d43 Reviewed-on: https://go-review.googlesource.com/c/go/+/415156 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com>
| * go/doc/comment: support links in lists in commentsBen Sarah Golightly2022-06-305-0/+131
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The proposed (#51082) new go doc comment additions supports lists, links, and doc links, but does not support links and doc links inside lists, so implemnent this. Fixes #53610 Change-Id: I4fa17d204fc9efa8f3633133e4a49e56cf1aa9bc Reviewed-on: https://go-review.googlesource.com/c/go/+/415174 Reviewed-by: Ben Golightly <golightly.ben@googlemail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
* | [dev.unified] all: merge master (993c387) into dev.unifiedMatthew Dempsky2022-06-306-20/+55
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: - test/run.go: textual conflict in 1.18 known failures list Merge List: + 2022-06-30 993c387032 os: simplify deadline fluctuation tests + 2022-06-30 4914e4e334 cmd/go/internal/modindex: remove spurious field from index_format documentation + 2022-06-30 981d5947af cmd/go: include module root in package index key + 2022-06-30 84db00ffd1 cmd/go: add a 'sleep' command for script tests + 2022-06-30 31b8c23c57 cmd/compile: fix prove pass when upper condition is <= maxint + 2022-06-30 17083a2fdf spec: retitle section on "Assignments" to "Assignment statements" + 2022-06-30 4d95fe6653 test: add regress test for #53619 + 2022-06-29 6a7c64fde5 debug/pe: add IMAGE_FILE_MACHINE_LOONGARCH{64,32} + 2022-06-29 b2cc0fecc2 net/http: preserve nil values in Header.Clone + 2022-06-29 64ef16e777 cmd/internal/obj/arm64: save LR and SP in one instruction for small frames + 2022-06-29 0750107074 go/token: use atomics not Mutex for last file cache + 2022-06-29 e5017a93fc net/http: don't strip whitespace from Transfer-Encoding headers + 2022-06-29 20760cff00 runtime: add race annotations to cbs.lock + 2022-06-29 e6c0546c54 crypto/x509/pkix: move crl deprecation message + 2022-06-29 3562977b6f cmd/internal/obj/mips,s390x,riscv: save LR after decrementing SP + 2022-06-29 d6481d5b96 runtime: add race annotations to metricsSema + 2022-06-29 bd1783e812 crypto/x509: improve RevocationList documentation + 2022-06-28 160414ca6a cmd/internal/obj/arm64: fix BITCON constant printing error + 2022-06-28 a30f434667 cmd/go: pass --no-decorate when listing git tags for a commit + 2022-06-28 3580ef9d64 os/exec: on Windows, suppress ErrDot if the implicit path matches the explicit one + 2022-06-28 34f3ac5f16 cmd/compile: fix generic inter-inter comparisons from value switch statements + 2022-06-28 7df0a002e6 cmd/go/internal/modfetch: cache latest revinfo in Versions func + 2022-06-28 d5bf9604aa test: add more tests for const decls with ommitted RHS expressions + 2022-06-28 533082d1a0 test: add test that gofrontend failed to compile + 2022-06-28 47e792e22e runtime: clean up unused function gosave on loong64 + 2022-06-28 a6e5be0d30 cmd/go: omit build metadata that may contain system paths when -trimpath is set + 2022-06-28 d3ffff2790 api: correct debug/pe issue number for Go 1.19 changes + 2022-06-28 751cae8855 cmd/go/internal/modload: fix doc comment + 2022-06-28 85d7bab91d go/printer: report allocs and set bytes + 2022-06-27 3af5280c00 net: really skip Windows PTR tests if we say we are skipping them + 2022-06-27 a42573c2f1 net: avoid darwin/arm64 platform bug in TestCloseWrite + 2022-06-27 68289f39f0 html/template: fix typo in content_test.go + 2022-06-27 c3bea70d9b cmd/link: link against libsynchronization.a for -race on windows + 2022-06-27 f093cf90bf test: add test that caused gofrontend crash + 2022-06-27 155612a9b9 test: add test that caused gofrontend crash + 2022-06-27 a861eee51a cmd/go: compile runtime/internal/syscall as a runtime package + 2022-06-27 8f9bfa9b7b crypto/internal/boring: factor Cache into crypto/internal/boring/bcache + 2022-06-26 351e0f4083 runtime: avoid fma in mkfastlog2table + 2022-06-26 416c953960 test: add test that gofrontend gets wrong + 2022-06-26 666d736ecb cmd/compile: do branch/label checks only once + 2022-06-26 6b309be7ab cmd/compile/internal/syntax: check fallthrough in CheckBranches mode + 2022-06-25 1821639b57 runtime: mark string comparison hooks as no split + 2022-06-25 3b594b9255 io: clarify SeekEnd offset value + 2022-06-25 4f45ec5963 cmd/go: prepend builtin prolog when checking for preamble errors + 2022-06-24 41e1d9075e strconv: avoid panic on invalid call to FormatFloat + 2022-06-24 bd4753905d internal/trace: add Go 1.19 test data + 2022-06-24 6b6c64b1cc cmd/internal/archive: don't rely on an erroneous install target in tests Change-Id: Ib43126833bf534c311730d4283d4d25381cd3428
| * go/token: use atomics not Mutex for last file cacheAlan Donovan2022-06-292-16/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, FileSet would cache the last *File found by a lookup, using a full (exclusive) mutex within FileSet.File, turning a logical read operation into an update. This was one of the largest sources of contention in gopls. This change uses atomic load/store on the 'last' field without a mutex. Also, in FileSet.AddFile, allocate the File outside the critical section; all the other operations are typically cheap. Fixes #53507 Change-Id: Ice8641650d8495b25b0428e9b9320837ff2ca7e1 Reviewed-on: https://go-review.googlesource.com/c/go/+/411909 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
| * test: add more tests for const decls with ommitted RHS expressionsRobert Griesemer2022-06-282-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add analogous tests to go/types and types2 test suites. Make sure "assert" built-in is available in type-checker tests. For #49157. For #53585. Change-Id: I092901ecb43eb4833c09bd8f5e38efbe0285babe Reviewed-on: https://go-review.googlesource.com/c/go/+/414795 Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
| * go/printer: report allocs and set bytesDaniel Martí2022-06-281-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We now get more than just time/op. name time/op Print-16 6.29ms ± 3% name speed Print-16 8.25MB/s ± 3% name alloc/op Print-16 483kB ± 0% name allocs/op Print-16 17.8k ± 0% Change-Id: I6b5e9a30a826ff8603724bd5983e6b7f5ec12708 Reviewed-on: https://go-review.googlesource.com/c/go/+/412554 Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Griesemer <gri@google.com> Auto-Submit: Robert Griesemer <gri@google.com> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Ian Lance Taylor <iant@google.com>
| * crypto/internal/boring: factor Cache into crypto/internal/boring/bcacheRuss Cox2022-06-271-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | Requested by the maintainers of the OpenSSL-based fork of Go+BoringCrypto, to make maintaining that fork easier. Change-Id: I770e70ecc12b589034da31edecf59c73b2c6e1dd Reviewed-on: https://go-review.googlesource.com/c/go/+/407135 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Russ Cox <rsc@golang.org>
* | [dev.unified] cmd/compile: drop package height from Unified IR importerCuong Manh Le2022-06-271-3/+1
|/ | | | | | | | | | | | | | CL 410342 removed package height, but still needs to keep writing out 0 for iexport for compatibility with existing importers. With Unified IR, we don't have to, so get rid of the package height completely. Change-Id: I84a285cbaddd7bb0833d45a24a6818231b4d2b71 Reviewed-on: https://go-review.googlesource.com/c/go/+/411014 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
* go/types, types2: print qualified object names in cycle errorsRobert Griesemer2022-06-241-4/+18
| | | | | | | | | Fixes #50788. Change-Id: Id1ed7d9c0687e3005e28598373fd5634178c78ca Reviewed-on: https://go-review.googlesource.com/c/go/+/413895 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
* go/types, types2: better errors for == when type sets are emptyRobert Griesemer2022-06-244-16/+42
| | | | | | | | | | | For #51525. Change-Id: I3762bc4a48a1aaab3b006b1ad1400f866892243c Reviewed-on: https://go-review.googlesource.com/c/go/+/413934 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
* go/types, types2: fix parameter order dependence in type inferenceRobert Griesemer2022-06-223-8/+5
| | | | | | | | | | | | | | | | | | | | | | | | | If we have more than two function arguments to a generic function, we may have arguments with named and unnamed types. If that is the case, permutate params and args such that the arguments with named types are first in the list. This way, independent of parameter ordering, the type inference will produce the same result. This extra step is not explicitly outlined in the spec yet but we all agree that (parameter) order independence is an invariant that we should uphold for type inference. As we move towards less operational and more descriptive rules for type inference, we will incorporate this property as well. The actual fix for this bug existed before 1.18 but was not enabled. This CL merely enables the fix (switches a flag) and adjusts some tests. Fixes #43056. Change-Id: Ie4e40cf8438dfd82fa94b78068e4f6f6f53f83e6 Reviewed-on: https://go-review.googlesource.com/c/go/+/413459 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
* runtime: convert flaky semaphore linearity test into benchmarkMichael Anthony Knyszek2022-06-211-4/+1
| | | | | | | | | | | | | | | | Also, add a benchmark for another case that was originally tested. Also also, remove all the dead code this now creates. Fixes #53428. Change-Id: Idbba88d3d31d38a8854fd5ed99001e394da27300 Reviewed-on: https://go-review.googlesource.com/c/go/+/412878 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> Auto-Submit: Michael Knyszek <mknyszek@google.com>
* test: add regress test for #53477Matthew Dempsky2022-06-211-0/+1
| | | | | | | | | | | | | This test already passes for GOEXPERIMENT=unified; add regress test to ensure it stays that way. Updates #53477. Change-Id: Ib7aa7428260595077052207899edcc044a6ab1c8 Reviewed-on: https://go-review.googlesource.com/c/go/+/413394 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: David Chase <drchase@google.com>
* test: add regress test for #53419Matthew Dempsky2022-06-171-0/+1
| | | | | | | | | | | | | | This currently works with GOEXPERIMENT=unified. Add a regress test to make sure it stays that way. Updates #53419. Change-Id: I2ea1f9039c59807fbd497d69a0420771f8d6d035 Reviewed-on: https://go-review.googlesource.com/c/go/+/413014 Run-TryBot: Matthew Dempsky <mdempsky@google.com> Auto-Submit: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/token: delete unused File.set fieldAlan Donovan2022-06-173-9/+1
| | | | | | | | | | | This field is only used for a sanity check in a test. Change-Id: I868ed10131ec33994ebb1b1d88f6740956824bd7 Reviewed-on: https://go-review.googlesource.com/c/go/+/409834 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
* go/parser: remove unused method checkBinaryExprRobert Griesemer2022-06-161-17/+0
| | | | | | | | | | Change-Id: Ica981657e50e30cbfa1757e8457819a479f11c7d Reviewed-on: https://go-review.googlesource.com/c/go/+/412775 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
* internal/goarch, internal/goos: update generators for syslist.goIan Lance Taylor2022-06-151-0/+4
| | | | | | | | | | | | | | | | | | | | Update the generator programs for the changes to syslist.go in CL 390274 and the changes to the generated files in CL 344955. Tested by running the programs and verifying that the files did not change. Fixes #53299 Change-Id: I2b2c5769f7e9283aa05c803256d2ea1eb9ad1547 Reviewed-on: https://go-review.googlesource.com/c/go/+/411334 Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/types, types2: add test case for issue for coverageRobert Griesemer2022-06-151-0/+19
| | | | | | | | | | | | The specific error doesn't occur anymore. Add a test to prevent regressions. For #50729. Change-Id: Ibf6ef6009b3d226b4f345b5a5657939915f19633 Reviewed-on: https://go-review.googlesource.com/c/go/+/412235 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* internal/testmath: add two-sample Welch's t-test for performance testsMichael Anthony Knyszek2022-06-131-1/+4
| | | | | | | | | | | | | | | | | This CL copies code from github.com/aclements/go-moremath/stats and github.com/aclements/go-moremath/mathx for Welch's t-test. Several existing tests in the Go repository check performance and scalability, and this import is part of a move toward a more rigorous measurement of both. Note that the copied code is already licensed to Go Authors, so there's no need to worry about additional licensing considerations. For #32986. Change-Id: I058630fab7216d1a589bb182b69fa2231e6f5475 Reviewed-on: https://go-review.googlesource.com/c/go/+/411395 Reviewed-by: Michael Pratt <mpratt@google.com>
* go/types, types2: only set instance context if packages matchRobert Findley2022-06-093-42/+60
| | | | | | | | | | | | | | | | | | | | | | | In CL 404885, we avoid infinite expansion of type instances by sharing a context between the expanding type and new instances created during expansion. This ensures that we do not create an infinite number of identical but distinct instances in the presence of reference cycles. This pins additional memory to the new instance, but no more (approximately) than would be pinned by the original expanding instance. However, we can do better: since type cycles are only possible within a single package, we only need to share the local context if the two types are in the same package. This reduces the scope of the shared local context, and in particular can avoid pinning the package of the expanding type to the package of the newly created instance. Updates #52728 Change-Id: Iad2c85f4ecf60125f1da0ba22a7fdec7423e0338 Reviewed-on: https://go-review.googlesource.com/c/go/+/410416 Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/types, types2: better error message for invalid use of constraint typeRobert Griesemer2022-06-072-2/+18
| | | | | | | | | Fixes #42881. Change-Id: If800c5f90c0034d192bf8b6649e5cfda96df48cb Reviewed-on: https://go-review.googlesource.com/c/go/+/410954 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
* go/types, types2: better error message if type is not in type setRobert Griesemer2022-06-072-1/+17
| | | | | | | | | Fixes #40350. Change-Id: Ia654d6b854971700ca618692a864265557122b23 Reviewed-on: https://go-review.googlesource.com/c/go/+/410876 Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
* go/types, types2: use | rather than ∪ when printing term listsRobert Griesemer2022-06-073-74/+74
| | | | | | | | | | | | | With this change, the termlist String() function prints termlists in the usual Go notation and thus we can use it in error reporting. Preparation for fixing #40350. For #40350. Change-Id: Ia28318841305de234a71af3146ce0c59f5e601a5 Reviewed-on: https://go-review.googlesource.com/c/go/+/410894 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Robert Findley <rfindley@google.com>
* go/doc/comment: add heuristics for common badly formatted commentsRuss Cox2022-06-067-99/+322
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a set of 55M Go doc comments drawn from the latest version of all public Go modules known to the module proxy in spring 2020, the current Go 1.19 gofmt reformats about 1.57M of them. Out of those 1.57M comments, inspection of random samples shows that around 5% of the changed comments contain unindented code snippets, multiline shell commands, or lists. For example: // Here is a greeting: // // func main() { // fmt.Println("hello, world") // } // Run this command: // // path/to/your/program -flag1=longargument1 \ // -flag2=longargument2 \ // -flag3 // There are three possibilities: // // - Unindented code snippets (or JSON objects) // in which the first and last line are unindented // but end in { and start with }, respectively. // - Unindented multiline shell commands // in which the lines end in \ // - Unindented lists, in which wrapped lines are indented. All three of these cases involve unindented lines next to indented lines that would according to the usual rules begin a pre block. Before this CL, they'd be reformatted to: // Here is a greeting: // // func main() { // // fmt.Println("hello, world") // // } // Run this command: // // path/to/your/program -flag1=longargument1 \ // // -flag2=longargument2 \ // -flag3 // There are three possibilities: // // - Unindented code snippets (or JSON objects) // // in which the first and last line are unindented // but end in { and start with }, respectively. // // - Unindented multiline shell commands // // in which the lines end in \ // // - Unindented lists, in which wrapped lines are indented. The fact that they are not already in canonical format gives us a signal that they might not mean what the usual rules would say. This CL takes advantage of that opening to apply a few heuristics to better handle these cases: 1. If an indented code block immediately follows (without a blank line) an unindented line ending in { or \, include the unindented line in the code block. 2. If an indented code block immediately precedes (without a blank line) an unindented line beginning with }, include the unindented line in the code block. 3. If an indented line immediately follows (without a blank line) an unindented line that starts with a list marker, assume this is an unindented list with a wrapped indented line, and treat all adjacent unindented lines starting with list markers as part of the list, stopping at any surrounding blank lines. This raises the fraction of “correctly” reformatted doc comments in the corpus from approximately 87% to approximately 93%. Change-Id: I7ac542eb085032d607a7caf3ba9020787b2978b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/410360 Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Roland Shoemaker <roland@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* all: boringcrypto post-merge cleanupRuss Cox2022-06-061-2/+4
| | | | | | | | | | | | | This CL addresses the comments on CL 403154. For #51940. Change-Id: I99bb3530916d469077bfbd53095bfcd1d2aa82ef Reviewed-on: https://go-review.googlesource.com/c/go/+/403976 Reviewed-by: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* go/doc/comment: do not turn ``` into “`Russ Cox2022-06-062-1/+12
| | | | | | | | | | | | | | | | | | | ``` is Markdown, not Go doc comment, but some small fraction of users get confused. In a set of 55M Go doc comments drawn from the latest version of all public Go modules known to the module proxy in spring 2020, the current Go 1.19 gofmt reformats about 1.57M of them. Out of those 1.57M comments, 8k of them (about 0.5%) contain ```. Instead of rewriting ``` to “`, leave it alone. For #51082. Change-Id: I1c8c88aac7ef75ec03e1a396b84ffe711c46f941 Reviewed-on: https://go-review.googlesource.com/c/go/+/410359 Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
* go/doc/comment: add doc commentRuss Cox2022-06-061-0/+36
| | | | | | | | | | | | A CL in the website repo will add go.dev/doc/comment. One of the final steps for #51082. Change-Id: I419b4f6dbb424a8a93a8d09db30f7321af9ae976 Reviewed-on: https://go-review.googlesource.com/c/go/+/410358 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* go/types, types2: simplify implementation of validType (fix TODO)Robert Griesemer2022-06-061-68/+35
| | | | | | | | | | | | | | | | | | | | Now that validType is using the correct type nest (CL 409694), the top entry of the type nest corresponds to the instantiated type. Thus we can use that type instance to look up the value of type parameters, there's no need anymore to create an environment to look up type arguments. Remove the need to pass around the environment and remove all associated types and functions. Updates #52698. Change-Id: Ie37eace88896386e667ef93c77a4fc3cd0be6eb9 Reviewed-on: https://go-review.googlesource.com/c/go/+/410294 Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Griesemer <gri@google.com>
* go/types, types2: use type nest to detect type cycles (fix validType)Robert Griesemer2022-06-063-47/+217
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | validType was using a global type info map to detect invalid recursive types, which was incorrect. Instead, change the algorithm as follows: - Rather than using a "seen" (or typeInfo) map which is cumbersome to update correctly, use the stack of embedding types (the type nest) to check whether a type is embedded within itself, directly or indirectly. - Use Identical for type comparisons which correctly considers identity of instantiated generic types. - As before, maintain the full path of types leading to a cycle. But unlike before, track the named types rather than their objects, for a smaller slice ([]*Named rather than []Object), and convert to an object list only when needed for error reporting. - As an optimization, keep track of valid *Named types (Checker.valids). This prevents pathological cases from consuming excessive computation time. - Add clarifying comments and document invariants. Based on earlier insights by David Chase (see also CL 408818). Fixes #52698. Change-Id: I5e4598c58afcf4ab987a426c5c4b7b28bdfcf5ea Reviewed-on: https://go-review.googlesource.com/c/go/+/409694 Reviewed-by: Robert Findley <rfindley@google.com> Run-TryBot: Robert Griesemer <gri@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/types, types2: ensure that named types never expand infinitelyRobert Findley2022-06-069-106/+196
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During type-checking, newly created instances share a type checking Context which de-duplicates identical instances. However, when unexpanded types escape the type-checking pass or are created via calls to Instantiate, they lack this shared context. As reported in #52728, this may lead to infinitely many identical but distinct types that are reachable via the API. This CL introduces a new invariant that ensures we don't create such infinitely expanding chains: instances created during expansion share a context with the type that led to their creation. During expansion, the expanding type passes its Context to any newly created instances. This ensures that cycles will eventually terminate with a previously seen instance. For example, if we have an instantiation chain T1[P]->T2[P]->T3[P]->T1[P], by virtue of this Context passing the expansion of T3[P] will find the instantiation T1[P]. In general, storing a Context in a Named type could lead to pinning types in memory unnecessarily, but in this case the Context pins only those types that are reachable from the original instance. This seems like a reasonable compromise between lazy and eager expansion. Our treatment of Context was a little haphazard: Checker.bestContext made it easy to get a context at any point, but made it harder to reason about which context is being used. To fix this, replace bestContext with Checker.context, which returns the type-checking context and panics on a nil receiver. Update all call-sites to verify that the Checker is non-nil when context is called. Also make it a panic to call subst with a nil context. Instead, update subst to explicitly accept a local (=instance) context along with a global context, and require that one of them is non-nil. Thread this through to the call to Checker.instance, and handle context updating there. Fixes #52728 Change-Id: Ib7f26eb8c406290325bc3212fda25421a37a1e8e Reviewed-on: https://go-review.googlesource.com/c/go/+/404885 Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Findley <rfindley@google.com>
* go/types, types2: store Named instance information separatelyRobert Findley2022-06-0611-77/+110
| | | | | | | | | | | | | | | | Separate instance information into an instance struct, to reduce memory footprint for non-instance Named types. This may induce a sense of deja-vu: we had a similar construct in the past that was removed as unnecessary. With additional new fields being added that only apply to instances, having a separate struct makes sense again. Updates #52728 Change-Id: I0bb5982d71c27e6b574bfb4f7b886a6aeb9c5390 Reviewed-on: https://go-review.googlesource.com/c/go/+/404884 Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/types, types2: eliminate methodList in favor of just using Named.muRobert Findley2022-06-065-145/+56
| | | | | | | | | | | | | | In order to clean up context after fully expanding a type (in subsequent CLs), we must use a common mutex. Eliminate the lazy methodList type, which keeps a sync.Once per method, in favor of Named.mu. Updates #52728 Change-Id: I2d13319276df1330ee53046ef1823b0167a258d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/404883 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
* go/types, types2: remove Named.once in favor of monotonic stateRobert Findley2022-06-067-141/+312
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduce a monotonic state variable to track the lifecycle of a named type, replacing the existing sync.Once. Having a single guard for the state of underlying and methods will allow for cleaning-up when the type is fully expanded. In the future, this state may also be used for detecting access to information such as underlying or methods before the type is fully set-up, though that will require rethinking our type-checking of invalid cyclic types. Also remove support for type-type inference. If we ever support this feature in the future (inference of missing type arguments for named type instances), it will likely involve additional machinery that does not yet exist. Remove the current partial support to simplify our internal APIs. In particular, this means that Named.resolver is only used for lazy loading. As a result, we can revert the lazy loader signature to its previous form. A lot of exposition is added for how Named types work. Along the way, the terminology we use to describe them is refined. Some microbenchmarks are added that were useful in evaluating the tradeoffs between synchronization mechanisms. Updates #52728 Change-Id: I4e147360bc6e5d8cd4f37e32e86fece0530a6480 Reviewed-on: https://go-review.googlesource.com/c/go/+/404875 Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* go/printer: if comment gets formatted away, don't squashIan Lance Taylor2022-05-253-0/+21
| | | | | | | | | | | | | We were dropping the preceding whitespace. Fixes #53059 Change-Id: Ide0d6a76c463a7481ec4883a8568f7f7b5e87e9f Reviewed-on: https://go-review.googlesource.com/c/go/+/408394 Reviewed-by: Robert Griesemer <gri@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
* internal/pkgbits: add Index typeMatthew Dempsky2022-05-252-8/+9
| | | | | | | | | | | | Element indices are very common in the pkgbits API, so introduce a new defined type to help make that clearer. Change-Id: I8f9493e2335601c740eb403d1fdcd11183122907 Reviewed-on: https://go-review.googlesource.com/c/go/+/407435 Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>