]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
2 years ago[dev.typeparams] all: merge master (c8f4e61) into dev.typeparams
Matthew Dempsky [Tue, 20 Jul 2021 19:46:13 +0000 (12:46 -0700)]
[dev.typeparams] all: merge master (c8f4e61) into dev.typeparams

Conflicts:

- src/runtime/internal/sys/zgoarch_386.go
- src/runtime/internal/sys/zgoarch_amd64.go
- src/runtime/internal/sys/zgoarch_arm.go
- src/runtime/internal/sys/zgoarch_arm64.go
- src/runtime/internal/sys/zgoarch_arm64be.go
- src/runtime/internal/sys/zgoarch_armbe.go
- src/runtime/internal/sys/zgoarch_mips.go
- src/runtime/internal/sys/zgoarch_mips64.go
- src/runtime/internal/sys/zgoarch_mips64le.go
- src/runtime/internal/sys/zgoarch_mips64p32.go
- src/runtime/internal/sys/zgoarch_mips64p32le.go
- src/runtime/internal/sys/zgoarch_mipsle.go
- src/runtime/internal/sys/zgoarch_ppc.go
- src/runtime/internal/sys/zgoarch_ppc64.go
- src/runtime/internal/sys/zgoarch_ppc64le.go
- src/runtime/internal/sys/zgoarch_riscv.go
- src/runtime/internal/sys/zgoarch_riscv64.go
- src/runtime/internal/sys/zgoarch_s390.go
- src/runtime/internal/sys/zgoarch_s390x.go
- src/runtime/internal/sys/zgoarch_sparc.go
- src/runtime/internal/sys/zgoarch_sparc64.go
- src/runtime/internal/sys/zgoarch_wasm.go

  On dev.typeparams, CL 328336 moved these files to internal/goarch;
  whereas on master, CL 333909 reserved GOARCH=loong64. For this CL,
  I resolved the conflict by simply running "go generate internal/goarch".

Merge List:

+ 2021-07-19 c8f4e6152d spec: correct example comment in Conversions from slice to array
+ 2021-07-19 1d91551b73 time: correct typo in documentation for UnixMicro
+ 2021-07-19 404127c30f cmd/compile: fix off-by-one error in traceback argument counting
+ 2021-07-19 6298cfe672 cmd/compile: fix typo in fatal message of builtinCall
+ 2021-07-19 49402bee36 cmd/{compile,link}: fix bug in map.zero handling
+ 2021-07-18 a66190ecee test/bench/go1: fix size for RegexpMatchMedium_32
+ 2021-07-18 650fc2117a text/scanner: use Go convention in Position doc comment
+ 2021-07-16 aa4e0f528e net/http:  correct capitalization in cancelTimeBody comment
+ 2021-07-15 0941dbca6a testing: clarify in docs that TestMain is advanced
+ 2021-07-15 69728ead87 cmd/go: update error messages in tests to match CL 332573
+ 2021-07-15 c1cc9f9c3d cmd/compile: fix lookup package of redeclared dot import symbol
+ 2021-07-15 21a04e3335 doc/go1.17: mention GOARCH=loong64
+ 2021-07-14 2b00a54baf go/build, runtime/internal/sys: reserve GOARCH=loong64
+ 2021-07-14 60ddf42b46 cmd/go: change link in error message from /wiki to /doc.
+ 2021-07-13 d8f348a589 cmd/go: remove a duplicated word from 'go help mod graph'
+ 2021-07-12 a98589711d crypto/tls: test key type when casting
+ 2021-07-12 cfbd73ba33 doc/go1.17: editing pass over the "Compiler" section
+ 2021-07-09 ab4085ce84 runtime/pprof: call runtime.GC twice in memory profile test

Change-Id: I1490a4c7e4c560659c21a4eb67d243f35d1f908e

2 years agospec: correct example comment in Conversions from slice to array
Piers [Mon, 19 Jul 2021 20:11:29 +0000 (20:11 +0000)]
spec: correct example comment in Conversions from slice to array

Fixes #47280

Change-Id: I78a8d235949b4878c7f075ac4ca37700e7e6c31c
GitHub-Last-Rev: 067f96eeb2c918eb4f775c428edc945c75af44d8
GitHub-Pull-Request: golang/go#47282
Reviewed-on: https://go-review.googlesource.com/c/go/+/335470
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Than McIntosh <thanm@google.com>

2 years agotime: correct typo in documentation for UnixMicro
helloPiers [Mon, 19 Jul 2021 20:08:50 +0000 (20:08 +0000)]
time: correct typo in documentation for UnixMicro

Fixes #47283.

Change-Id: Ibdc35433d22be3caa70197b6a95c66999812a16a
GitHub-Last-Rev: 75962b029467a5e26e1ee78a38bf01c954445ea1
GitHub-Pull-Request: golang/go#47284
Reviewed-on: https://go-review.googlesource.com/c/go/+/335549
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Than McIntosh <thanm@google.com>

2 years agocmd/compile: fix off-by-one error in traceback argument counting
Cherry Mui [Wed, 14 Jul 2021 22:52:44 +0000 (18:52 -0400)]
cmd/compile: fix off-by-one error in traceback argument counting

For traceback argument printing, we want to print at most 10
words, then print "..." if there are still more args and/or
fields. The current code has off-by-one error that for 11
non-aggregate typed args, it prints the first 10 but without the
"...". Also, for aggregate-typed args, in some cases it may print
an extra "..." when there is actually no more fields.

The problem for this is that visitType return false (meaning not
to continue visiting) if it reaches the limit anywhere during the
recursive visit. It doesn't distinguish whether it has printed
anything for the current arg. If it reaches the limit before it
prints anything, it means that we're visiting the extra arg/field,
so the caller should print "..." and stop. If it prints
something then reaches the limit, however, the caller should keep
going, and only print "..." at the next iteration when there is
actually an extra arg/field. This CL does so.

Fixes #47159.

Change-Id: I93fc25b73ada2b5a98df780c45e5b0c9565dc2fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/334710
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years ago[dev.typeparams] go/types: fix the type parameter index in applyTypeFunc
Rob Findley [Fri, 11 Jun 2021 16:40:42 +0000 (12:40 -0400)]
[dev.typeparams] go/types: fix the type parameter index in applyTypeFunc

We should preserve type parameter indices when transforming them using
applyTypeFunc.

Change-Id: Ib75f5cf1a146bd7e6850368fa954c1affcba3ad1
Reviewed-on: https://go-review.googlesource.com/c/go/+/327269
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

2 years agocmd/compile: fix typo in fatal message of builtinCall
Leonard Wang [Sun, 11 Jul 2021 03:46:26 +0000 (11:46 +0800)]
cmd/compile: fix typo in fatal message of builtinCall

Change-Id: I523d5fd810b82154a204670d46fc250a0fc66791
Reviewed-on: https://go-review.googlesource.com/c/go/+/333849
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

2 years ago[dev.typeparams] go/types: more consistent handling of predeclared "any"
Rob Findley [Mon, 19 Jul 2021 14:58:40 +0000 (10:58 -0400)]
[dev.typeparams] go/types: more consistent handling of predeclared "any"

This is a port of CL 334911 to go/types.

Change-Id: I2cafdc76cb4d06ba82188c530f35952c1f77d292
Reviewed-on: https://go-review.googlesource.com/c/go/+/335569
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: embedding stand-alone type parameters is not permitted
Rob Findley [Sat, 17 Jul 2021 00:57:10 +0000 (20:57 -0400)]
[dev.typeparams] go/types: embedding stand-alone type parameters is not permitted

This is a port of CL 334151 to go/types.

Fixes #47127

Change-Id: I57d69c498d2649a9e1657559e4c0271333096c88
Reviewed-on: https://go-review.googlesource.com/c/go/+/335082
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: fix generic type indirection
Rob Findley [Sat, 17 Jul 2021 00:50:18 +0000 (20:50 -0400)]
[dev.typeparams] go/types: fix generic type indirection

This is a port of CL 333890 to go/types.

Change-Id: I8ee20f405dad98083bb5e91636044d132a95d909
Reviewed-on: https://go-review.googlesource.com/c/go/+/335081
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: interface identity must consider full type set
Rob Findley [Sat, 17 Jul 2021 00:46:39 +0000 (20:46 -0400)]
[dev.typeparams] go/types: interface identity must consider full type set

This is a port of CL 333889 to go/types.

Change-Id: I66cefb81a33f4677efc18c1ca923ded374a87f12
Reviewed-on: https://go-review.googlesource.com/c/go/+/335080
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: cleanups around receiver type checks
Rob Findley [Sat, 17 Jul 2021 00:40:58 +0000 (20:40 -0400)]
[dev.typeparams] go/types: cleanups around receiver type checks

This is a port of CL 333770 to go/types, adjusted for the error
reporting API and to not support compiler error messages. An error
message changed (to 'invalid receiver type' from just 'invalid
receiver'), so a test had to be adjusted.

Change-Id: I166e8831d8c9f98ebfb0270fe5221586fc112825
Reviewed-on: https://go-review.googlesource.com/c/go/+/335079
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: implement delete(m, k) where m is of type parameter type
Rob Findley [Sat, 17 Jul 2021 00:34:00 +0000 (20:34 -0400)]
[dev.typeparams] go/types: implement delete(m, k) where m is of type parameter type

This is a port of CL 333729 to go/types.

Change-Id: I8682f549a7a15124b1b338f8c73e83a57d138368
Reviewed-on: https://go-review.googlesource.com/c/go/+/335078
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: implement close(ch) where ch is of type parameter type
Rob Findley [Sat, 17 Jul 2021 00:30:45 +0000 (20:30 -0400)]
[dev.typeparams] go/types: implement close(ch) where ch is of type parameter type

This is a port of CL 333713 to go/types.

Change-Id: I517f52592f65cc76e11a12d9148b20c12d9e3e81
Reviewed-on: https://go-review.googlesource.com/c/go/+/335077
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: implement ch <- x where ch is of type parameter type
Rob Findley [Sat, 17 Jul 2021 00:22:59 +0000 (20:22 -0400)]
[dev.typeparams] go/types: implement ch <- x where ch is of type parameter type

This is a port of CL 333712 to go/types, adjusted for the different
error reporting API and to position errors on the arrows.

Fixes #43671

Change-Id: I7d2de249e86d272c89a046f60e632e75848ff865
Reviewed-on: https://go-review.googlesource.com/c/go/+/335076
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: implement <-ch where ch is of type parameter type
Rob Findley [Sat, 17 Jul 2021 00:16:27 +0000 (20:16 -0400)]
[dev.typeparams] go/types: implement <-ch where ch is of type parameter type

This is a port of CL 333709 to go/types, adjusted for the different
error API.

Fixes #43671

Change-Id: Ifd340149bfbcabe401cec74398cb83f2ae812e51
Reviewed-on: https://go-review.googlesource.com/c/go/+/335075
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: move methods on *Named into named.go
Rob Findley [Sat, 17 Jul 2021 00:07:01 +0000 (20:07 -0400)]
[dev.typeparams] go/types: move methods on *Named into named.go

This is a port of CL 333671 to go/types.

Change-Id: Ic2f66b49f1db68fb93d5095131733e99a37b9cbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/335074
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: use InstantiateLazy to create instance types (cleanup)
Rob Findley [Fri, 16 Jul 2021 23:58:59 +0000 (19:58 -0400)]
[dev.typeparams] go/types: use InstantiateLazy to create instance types (cleanup)

This is a port of CL 333669 to go/types, adjusted for the position and
IndexExpr APIs, and excluding the noder changes.

Change-Id: I3ac4bbf271947c3cf80ab04c462a91657316f4fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/335073
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: move instantiation code to instantiate.go (cleanup)
Rob Findley [Fri, 16 Jul 2021 23:52:46 +0000 (19:52 -0400)]
[dev.typeparams] go/types: move instantiation code to instantiate.go (cleanup)

This is a port of CL 333589 to go/types.

Change-Id: Ib9fb1b09e10c400e62d20b55ff0558f3a92fc0eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/335072
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: replace types2.Instantiate with Checker.Instantiate
Rob Findley [Fri, 16 Jul 2021 23:49:43 +0000 (19:49 -0400)]
[dev.typeparams] go/types: replace types2.Instantiate with Checker.Instantiate

This is a partial port of CL 333569 containing just changes to go/types.
Changes to the importer wil be made in a separate CL.

Change-Id: I9383e260b76402875ca6eb23c4478a6a3e8c1f0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/335071
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

2 years ago[dev.typeparams] go/types: update TypeParam APIs to match types2
Rob Findley [Fri, 16 Jul 2021 23:01:16 +0000 (19:01 -0400)]
[dev.typeparams] go/types: update TypeParam APIs to match types2

This is a partial port of CL 323029, consisting only of changes to
go/types. Changes to the importer will be made in a separate CL.

Change-Id: I3b300f5e8f4df36c2c87e3f164705cd3c36218ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/335145
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: remove unnecessary guard from NewInterfaceType
Rob Findley [Fri, 16 Jul 2021 18:54:21 +0000 (14:54 -0400)]
[dev.typeparams] go/types: remove unnecessary guard from NewInterfaceType

This is a partial port of CL 322609, containing only changes to
go/types. Importer changes will be made in a separate CL.

Change-Id: I50af3c1ed5e949bb28a3462d717c0eb29a5f31ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/335144
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: add some missing APIs for the importer
Rob Findley [Fri, 16 Jul 2021 18:43:30 +0000 (14:43 -0400)]
[dev.typeparams] go/types: add some missing APIs for the importer

This is a partial port of CL 319930, containing only changes to
go/types. Importer changes will be made in a separate CL.

The TypeParams APIs are left unexported for now; they will be exported
when they are needed.

Change-Id: I74bd246d4c174cb38f8360d921c733fa03900eab
Reviewed-on: https://go-review.googlesource.com/c/go/+/335143
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: recursive substitution must terminate (bug fix)
Rob Findley [Fri, 16 Jul 2021 18:30:15 +0000 (14:30 -0400)]
[dev.typeparams] go/types: recursive substitution must terminate (bug fix)

This is a port of CL 333383 to go/types.

Change-Id: I7ff68116cbe63337dbcc834c473a2a5588274e36
Reviewed-on: https://go-review.googlesource.com/c/go/+/335115
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: use scope numbers to identify local types
Rob Findley [Fri, 16 Jul 2021 18:20:18 +0000 (14:20 -0400)]
[dev.typeparams] go/types: use scope numbers to identify local types

This is a port of CL 333192 to go/types.

Change-Id: I12fd6b682d40c4d30b9ac0e87c463843cf5030d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/335114
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: support local defined types
Rob Findley [Fri, 16 Jul 2021 17:27:57 +0000 (13:27 -0400)]
[dev.typeparams] go/types: support local defined types

This is a port of CL 327170 to go/types. Tests were not ported; they can
be added later.

Change-Id: Ic9fd681ac06dd187c1715efaf882b11353bc395a
Reviewed-on: https://go-review.googlesource.com/c/go/+/335113
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: don't permit method calls on ptr to type parameter receivers
Rob Findley [Fri, 16 Jul 2021 17:15:24 +0000 (13:15 -0400)]
[dev.typeparams] go/types: don't permit method calls on ptr to type parameter receivers

This is a port of CL 332609 to go/types.

Change-Id: I3482ea1b97bc7101b987ef312cd6cade80a5843f
Reviewed-on: https://go-review.googlesource.com/c/go/+/335112
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agocmd/{compile,link}: fix bug in map.zero handling
Than McIntosh [Thu, 15 Jul 2021 20:29:36 +0000 (16:29 -0400)]
cmd/{compile,link}: fix bug in map.zero handling

In CL 326211 a change was made to switch "go.map.zero" symbols from
non-pkg DUPOK symbols to hashed symbols. The intent of this change was
ensure that in cases where there are multiple competing go.map.zero
symbols feeding into a link, the largest map.zero symbol is selected.
The change was buggy, however, and resulted in duplicate symbols in
the final binary (see bug cited below for details). This duplication
was relatively benign for linux/ELF, but causes duplicate definition
errors on Windows.

This patch switches "go.map.zero" symbols back from hashed symbols to
non-pkg DUPOK symbols, and updates the relevant code in the loader to
ensure that we do the right thing when there are multiple competing
DUPOK symbols with different sizes.

Fixes #47185.

Change-Id: I8aeb910c65827f5380144d07646006ba553c9251
Reviewed-on: https://go-review.googlesource.com/c/go/+/334930
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years ago[dev.typeparams] Separate out gcshape types that are instantiated types
Dan Scales [Fri, 9 Jul 2021 23:27:22 +0000 (16:27 -0700)]
[dev.typeparams] Separate out gcshape types that are instantiated types

Distinguish the gcshape of all top-level instantiated type from normal
concrete types, even if they have the exact same underlying "shape",
because in a function instantiation, any method call on this type arg
will be a generic method call (requiring a dictionary), rather than a
direct method call on the underlying type (no dictionary).

So, we add the instshape prefix to the gcshape name for instantiated
types, and we make it a defined type with that name.

Change-Id: I33056269d24f3451a2632a5ce6a481108f533c9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/335169
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2 years agotest/bench/go1: fix size for RegexpMatchMedium_32
nimelehin [Fri, 16 Jul 2021 20:41:21 +0000 (20:41 +0000)]
test/bench/go1: fix size for RegexpMatchMedium_32

Change-Id: Idc67abb95248bc010820a89dd6096a2da334e723
GitHub-Last-Rev: ae9014b011efb2692f853888c1860920d1acc3cb
GitHub-Pull-Request: golang/go#47254
Reviewed-on: https://go-review.googlesource.com/c/go/+/335189
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

2 years agotext/scanner: use Go convention in Position doc comment
mehradsadeghi [Fri, 16 Jul 2021 21:25:28 +0000 (21:25 +0000)]
text/scanner: use Go convention in Position doc comment

Change-Id: Ib872f139af7bfb0a75cc21dace5358fe8fcf2cf0
GitHub-Last-Rev: 8fd5ab01fab3bc1d7701092f31071d07ab79acc5
GitHub-Pull-Request: golang/go#47250
Reviewed-on: https://go-review.googlesource.com/c/go/+/335149
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Robert Griesemer <gri@golang.org>

2 years ago[dev.typeparams] go/types: replace optype() with under() in various cases (cleanup)
Rob Findley [Fri, 16 Jul 2021 17:03:06 +0000 (13:03 -0400)]
[dev.typeparams] go/types: replace optype() with under() in various cases (cleanup)

This is a port of CL 332555 to go/types.

Change-Id: I9b26bba8b605f5bbbd8f0f81fd6651a4a3ff4b57
Reviewed-on: https://go-review.googlesource.com/c/go/+/335111
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

2 years ago[dev.typeparams] go/types: clean up index expr implementation for type parameters
Rob Findley [Fri, 16 Jul 2021 16:54:37 +0000 (12:54 -0400)]
[dev.typeparams] go/types: clean up index expr implementation for type parameters

This is a port of CL 332553 to go/types. The "expr" variable is renamed to
"e" in Checker.indexExpr to be consistent with types2.

Change-Id: I7905bebf2e8dab47256361362b16becf7596cf95
Reviewed-on: https://go-review.googlesource.com/c/go/+/335110
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>

2 years ago[dev.typeparams] go/types: disallow "free" type parameter as RHS of a type declaration
Rob Findley [Fri, 16 Jul 2021 16:45:35 +0000 (12:45 -0400)]
[dev.typeparams] go/types: disallow "free" type parameter as RHS of a type declaration

This is a port of CL 332411 to go/types. methodset_test.go is similarly
updated.

Change-Id: I332b1837a954acc9d3b7e0e2ad2bec3425f088f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/335109
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>

2 years ago[dev.typeparams] go/types: move (remaining) type decls into their own files (cleanup)
Rob Findley [Fri, 16 Jul 2021 14:59:53 +0000 (10:59 -0400)]
[dev.typeparams] go/types: move (remaining) type decls into their own files (cleanup)

This is a port of CL 332093 to go/types. A missing comment is added to
named.go, and some TODOs were added to converge on the TypeParam API.

Change-Id: I781a1d0d3fc6c11bb323123e954c106094d998ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/335040
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: move Interface type decl into interface.go (cleanup)
Rob Findley [Fri, 16 Jul 2021 14:45:51 +0000 (10:45 -0400)]
[dev.typeparams] go/types: move Interface type decl into interface.go (cleanup)

This is a port of CL 332092 to go/types.

Change-Id: I9971c49570424368575108832eac0cd978eb3fe6
Reviewed-on: https://go-review.googlesource.com/c/go/+/335039
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: move Signature type decl into signature.go (cleanup)
Rob Findley [Fri, 16 Jul 2021 14:43:26 +0000 (10:43 -0400)]
[dev.typeparams] go/types: move Signature type decl into signature.go (cleanup)

This is a port of CL 332091 to go/types. Notably types.Signature is
missing APIs for RParams. This is left for a later CL, when the API is
finalized.

Change-Id: I70b664d656e8c1e32958a75e1d13eab5f3281bf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/335038
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: move Struct type decl into struct.go (cleanup)
Rob Findley [Fri, 16 Jul 2021 14:39:55 +0000 (10:39 -0400)]
[dev.typeparams] go/types: move Struct type decl into struct.go (cleanup)

This is a port of CL 332090 to go/types.

Change-Id: Idc480374f5efe0e7f34f76f37ffd02a3aef59c67
Reviewed-on: https://go-review.googlesource.com/c/go/+/335037
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: rename newTypeSet -> computeTypeSet
Rob Findley [Fri, 16 Jul 2021 14:36:42 +0000 (10:36 -0400)]
[dev.typeparams] go/types: rename newTypeSet -> computeTypeSet

This is a port of CL 332089 to go/types.

Change-Id: I39321eaee184c8204bd255b7770a0770ecb25fda
Reviewed-on: https://go-review.googlesource.com/c/go/+/335036
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: make Interface.obj a *TypeName
Rob Findley [Fri, 16 Jul 2021 14:33:59 +0000 (10:33 -0400)]
[dev.typeparams] go/types: make Interface.obj a *TypeName

This is a straightforward port of CL 332011 to go/types.

Change-Id: I682791886c8496c52094f3688e36934afbd7a241
Reviewed-on: https://go-review.googlesource.com/c/go/+/335035
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: delay interface check for type bounds
Rob Findley [Fri, 16 Jul 2021 14:27:17 +0000 (10:27 -0400)]
[dev.typeparams] go/types: delay interface check for type bounds

This is a port of CL 331690 to go/types. It diverges from that CL due to
the different representation of Fields in the AST.

Change-Id: I3ae9ac3a0172dc58ac748f28772d87b00db0732a
Reviewed-on: https://go-review.googlesource.com/c/go/+/335034
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/internal/typeparams: remove the Enabled guard
Rob Findley [Fri, 16 Jul 2021 13:51:19 +0000 (09:51 -0400)]
[dev.typeparams] go/internal/typeparams: remove the Enabled guard

Type parameters are now always enabled. Users should guard against type
checking generic code by using the types.Config.GoVersion field.

This cleans up some differences with types2.

Change-Id: Ie3e35a549e456a90a10d6a7e158ff58653cc1394
Reviewed-on: https://go-review.googlesource.com/c/go/+/335033
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: "comparable" must not be visible before Go 1.18
Rob Findley [Fri, 16 Jul 2021 13:44:08 +0000 (09:44 -0400)]
[dev.typeparams] go/types: "comparable" must not be visible before Go 1.18

This is a straightforward port of CL 331517 to go/types.

Change-Id: Id00761fd5dffb4d09e19f086d18ddc20f11528d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/335032
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: move newTypeSet function into typeset.go
Rob Findley [Fri, 16 Jul 2021 13:39:05 +0000 (09:39 -0400)]
[dev.typeparams] go/types: move newTypeSet function into typeset.go

This is a straightforward port of CL 331515 to go/types.

Change-Id: I05c687e7dd7a64a8a7815c4483ff7fbb06b37627
Reviewed-on: https://go-review.googlesource.com/c/go/+/335031
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: move embedding positions from Checker to Interface
Rob Findley [Fri, 16 Jul 2021 13:34:34 +0000 (09:34 -0400)]
[dev.typeparams] go/types: move embedding positions from Checker to Interface

This is a straightforward port of CL 331514 to go/types, with minor
adjustments for the different position API.

Change-Id: I714b3f1cd5a0e8d249912bb589d456885a87e167
Reviewed-on: https://go-review.googlesource.com/c/go/+/335030
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: remove unused *Checker arguments (cleanup)
Rob Findley [Fri, 16 Jul 2021 13:21:36 +0000 (09:21 -0400)]
[dev.typeparams] go/types: remove unused *Checker arguments (cleanup)

This is a straightforward port of CL 331512 to go/types. API usage in
methodset.go was also updated.

Change-Id: I6701265c9d2ae40eb9aa0ea5f00c98ce3516edab
Reviewed-on: https://go-review.googlesource.com/c/go/+/335009
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: remove typeparams wrappers and aliases
Rob Findley [Fri, 16 Jul 2021 03:18:59 +0000 (23:18 -0400)]
[dev.typeparams] go/types: remove typeparams wrappers and aliases

These wrappers and aliases were necessary when we had different versions
of the API depending on the typeparams build constraint, but now they're
just boilerplate. Remove them.

Notably the documentation for types.Info is restored.

Change-Id: I5363d1d5df47649c2641c03328dfba45b1456278
Reviewed-on: https://go-review.googlesource.com/c/go/+/334895
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: introduce type set abstraction for interfaces
Rob Findley [Fri, 16 Jul 2021 02:49:00 +0000 (22:49 -0400)]
[dev.typeparams] go/types: introduce type set abstraction for interfaces

This is a port of CL 329309 to go/types, with minor updates for API
differences and to handle methodset.go, which doesn't exist in types2.

A couple pre-existing comments were adjusted to match types2.

Change-Id: I3fd556e1326013a694ff5edb8518ca24c27bd10b
Reviewed-on: https://go-review.googlesource.com/c/go/+/334894
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] go/types: port lazy import resolution from types2
Rob Findley [Fri, 16 Jul 2021 02:06:38 +0000 (22:06 -0400)]
[dev.typeparams] go/types: port lazy import resolution from types2

This is a straightforward port of CL 323569 to go/types. It is
line-for-line identical, except where names are unexported to preserve
the current go/types API.

Change-Id: I4c78211bff90f982ca2e90ed224946716118ee31
Reviewed-on: https://go-review.googlesource.com/c/go/+/334893
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[dev.typeparams] cmd/compile: use dictionary to convert arguments of ==, != to interfaces
Keith Randall [Mon, 12 Jul 2021 23:12:55 +0000 (16:12 -0700)]
[dev.typeparams] cmd/compile: use dictionary to convert arguments of ==, != to interfaces

When comparing a value whose type is a type parameter to an interface,
we need to convert that type parameter to an interface using the dictionary
entries.

Change-Id: I409c9e36e376fe4ef8163407d0fd4e84496d5b65
Reviewed-on: https://go-review.googlesource.com/c/go/+/334150
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2 years ago[dev.typeparams] cmd/compile: fix small -G=3 issues for tests disabled in run.go
Dan Scales [Sun, 11 Jul 2021 20:06:54 +0000 (13:06 -0700)]
[dev.typeparams] cmd/compile: fix small -G=3 issues for tests disabled in run.go

 - set correct position for closure capture variable in (*irgen).use()
   (issue20250.go) Also, evaluate rhs, lhs in that order in assignment
   statements to match noder1 (affects ordering of closure variables).

 - make sure to set Assign flag properly in (*irgen).forStmt() for range
   variables which are map accesses (issue9691.go)

 - make sure CheckSize() is call on the base type for top-level types
   converted by (*irgen).typ() that are pointer types (issue20174.go and
   issue37837.go)

 - deal with parentheses properly in validation function
   (*irgen).validate() (issue17270.go)

 - avoid HasNil call on type TTYPEPARAM - types2 typechecker will have
   already checked validity of the typeparam having nil value (new test
   issue39755.go)

Change-Id: Ie68004d964698aea047e19e7dcd79b297e9d47ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/334733
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2 years ago[dev.typeparams] cmd/compile/internal/types2: more consistent handling of predeclared...
Robert Griesemer [Thu, 15 Jul 2021 23:42:25 +0000 (16:42 -0700)]
[dev.typeparams] cmd/compile/internal/types2: more consistent handling of predeclared "any"

Rather than removing "any" from the universe scope, keep it predeclared
but provide a better error message.

While at it, remove some unnecessary type assertions.

Change-Id: I10603274282ea6afc107f703ab194f32bd334dd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/334911
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agonet/http: correct capitalization in cancelTimeBody comment
shota3506 [Tue, 13 Jul 2021 21:27:05 +0000 (21:27 +0000)]
net/http:  correct capitalization in cancelTimeBody comment

Change-Id: I7acda22c01c5350ebf5ddabb1c12af96d368de5d
GitHub-Last-Rev: 3e5c022f8764d4abf91c964ceb4fc0e01ebd1352
GitHub-Pull-Request: golang/go#47160
Reviewed-on: https://go-review.googlesource.com/c/go/+/334229
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

2 years ago[dev.typeparams] go/*: switch from ListExpr to MultiIndexExpr
Rob Findley [Fri, 11 Jun 2021 14:58:43 +0000 (10:58 -0400)]
[dev.typeparams] go/*: switch from ListExpr to MultiIndexExpr

When instantiating a generic type or function with multiple type
arguments, we need to represent an index expression with multiple
indexes in the AST. Previous to this CL this was done with a new
ast.ListExpr node, which allowed packing multiple expressions into a
single ast.Expr. This compositional pattern can be both inefficient and
cumbersome to work with, and introduces a new node type that only exists
to augment the meaning of an existing node type.

By comparison, other specializations of syntax are given distinct nodes
in go/ast, for example variations of switch or for statements, so the
use of ListExpr was also (arguably) inconsistent.

This CL removes ListExpr, and instead adds a MultiIndexExpr node, which
is exactly like IndexExpr but allows for multiple index arguments. This
requires special handling for this new node type, but a new wrapper in
the typeparams helper package largely mitigates this special handling.

Change-Id: I65eb29c025c599bae37501716284dc7eb953b2ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/327149
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

2 years ago[dev.typeparams] cmd/compile: make TestUnifiedCompare insensitive to default -G level
Matthew Dempsky [Thu, 15 Jul 2021 20:06:13 +0000 (13:06 -0700)]
[dev.typeparams] cmd/compile: make TestUnifiedCompare insensitive to default -G level

The test currently fails if the default -G level is changed from 0 to
3, and it only makes sense to run in -G=0 mode anyway. So might as
well hard code it that way.

Change-Id: I026d25d567157df5d3f2ca3c68d31d75d9c74532
Reviewed-on: https://go-review.googlesource.com/c/go/+/334910
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2 years agotesting: clarify in docs that TestMain is advanced
Matt T. Proud [Wed, 14 Jul 2021 20:42:31 +0000 (22:42 +0200)]
testing: clarify in docs that TestMain is advanced

Beginner and intermediate Go users periodically use TestMain when
requirements do not necessitate TestMain (exceeding least-mechanism
design). This commit expands package testing's documentation to convey
that the TestMain feature itself is somewhat low-level and potentially
unsuitable for casual testing where ordinary test functions would
suffice.

Fixes #42161
Updates #44200

Change-Id: I91ba0b048c3d6f79110fe8f0fbb58d896edca366
Reviewed-on: https://go-review.googlesource.com/c/go/+/334649
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2 years agocmd/go: update error messages in tests to match CL 332573
Bryan C. Mills [Thu, 15 Jul 2021 18:48:45 +0000 (14:48 -0400)]
cmd/go: update error messages in tests to match CL 332573

I neglected to run the 'longtest' builder, and the tests
that cover the error message changed in CL 332573 apparently
do not run in short mode.

Updates #36460
Updates #42661

Change-Id: I53500ddaca8ac9f0dfaab538923b3c9a4f71665e
Reviewed-on: https://go-review.googlesource.com/c/go/+/334889
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

2 years agocmd/compile: fix lookup package of redeclared dot import symbol
Cuong Manh Le [Wed, 14 Jul 2021 17:56:44 +0000 (00:56 +0700)]
cmd/compile: fix lookup package of redeclared dot import symbol

The compiler is relying on Sym.Def field to lookup symbol package in
DotImportRefs map. But the Sym.Def field is clear whenever the compiler
finish processing a file. If the dot import happen in file A, then the
redeclaration happen in file B, then the symbol lookup in file B will
see a nil Sym.Def, that cause the compiler crashes.

To fix this, we can interate over DotImportRefs and check for matching
symbol name and return the corresponding package. Though this operation
can be slow, but it only happens in invalid program, when printing error
message, so it's not worth to optimize it further.

Fixes #47201

Change-Id: I4ca1cb0a8e7432b19cf71434592a4cbb58d54adf
Reviewed-on: https://go-review.googlesource.com/c/go/+/334589
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2 years agodoc/go1.17: mention GOARCH=loong64
Ian Lance Taylor [Wed, 14 Jul 2021 23:04:49 +0000 (16:04 -0700)]
doc/go1.17: mention GOARCH=loong64

For #46229

Change-Id: I54d01d90f2b0c892d76121f1350c0e8cf4b2772f
Reviewed-on: https://go-review.googlesource.com/c/go/+/334729
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2 years ago[dev.typeparams] cmd/compile/internal/types2: embedding stand-alone type parameters...
Robert Griesemer [Tue, 13 Jul 2021 05:39:39 +0000 (22:39 -0700)]
[dev.typeparams] cmd/compile/internal/types2: embedding stand-alone type parameters is not permitted

For #47127.

Change-Id: Ie979ff56ae7c2dd0e5ce0ff39588f98ae68b5ee9
Reviewed-on: https://go-review.googlesource.com/c/go/+/334151
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: fix generic type indirection
Robert Griesemer [Sun, 11 Jul 2021 22:59:22 +0000 (15:59 -0700)]
[dev.typeparams] cmd/compile/internal/types2: fix generic type indirection

Change-Id: If25ceb2aa403b94608760be331faa2aff11c47cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/333890
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: interface identity must consider full...
Robert Griesemer [Sun, 11 Jul 2021 22:27:49 +0000 (15:27 -0700)]
[dev.typeparams] cmd/compile/internal/types2: interface identity must consider full type set

There is no (obvious) way to test this at the moment because we
don't permit such constraint interfaces as ordinary types.

Change-Id: Ieeec023ed82a2c71ed50d111f26916aba4a59099
Reviewed-on: https://go-review.googlesource.com/c/go/+/333889
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: cleanups around receiver type checks
Robert Griesemer [Sat, 10 Jul 2021 04:18:12 +0000 (21:18 -0700)]
[dev.typeparams] cmd/compile/internal/types2: cleanups around receiver type checks

Generic receiver types may be defined such that an instantiated
receiver ends up being a pointer type. Disallow them as we do
for non-generic receivers.

Change-Id: I6612a52615a2999375c35aa1d69ab42f37d9f55d
Reviewed-on: https://go-review.googlesource.com/c/go/+/333770
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: implement delete(m, k) where m is of...
Robert Griesemer [Sat, 10 Jul 2021 02:03:48 +0000 (19:03 -0700)]
[dev.typeparams] cmd/compile/internal/types2: implement delete(m, k) where m is of type parameter type

Change-Id: Iaf33c15128af911b6101df9885cb8b5a8495b942
Reviewed-on: https://go-review.googlesource.com/c/go/+/333729
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: implement close(ch) where ch is of...
Robert Griesemer [Sat, 10 Jul 2021 01:26:57 +0000 (18:26 -0700)]
[dev.typeparams] cmd/compile/internal/types2: implement close(ch) where ch is of type parameter type

Change-Id: I45189468553e83390fd2640b5708c60a7852fbb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/333713
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: implement ch <- x where ch is of type...
Robert Griesemer [Sat, 10 Jul 2021 00:43:25 +0000 (17:43 -0700)]
[dev.typeparams] cmd/compile/internal/types2: implement ch <- x where ch is of type parameter type

For #47115.

Change-Id: Ib9c8652c0346029369735ccf7ee9098ab1ae7fd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/333712
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: implement <-ch where ch is of type...
Robert Griesemer [Sat, 10 Jul 2021 00:12:07 +0000 (17:12 -0700)]
[dev.typeparams] cmd/compile/internal/types2: implement <-ch where ch is of type parameter type

For #43671

Change-Id: I7db4b3886fab44ec0de7c0935e0ab21c26e3335c
Reviewed-on: https://go-review.googlesource.com/c/go/+/333709
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/build, runtime/internal/sys: reserve GOARCH=loong64
WANG Xuerui [Mon, 12 Jul 2021 04:40:28 +0000 (04:40 +0000)]
go/build, runtime/internal/sys: reserve GOARCH=loong64

Per discussion at #46229 we are taking the "loong64" GOARCH value for
the upcoming LoongArch 64-bit port. It is not clear whether any 32-bit
non-bare-metal userland will exist for LoongArch, so only reserve
"loong64" for now.

Change-Id: I97d262b4ab68ff61c22ccf83e26baf70eefd568d
GitHub-Last-Rev: ecdd8c53bdee57fec093ddba18ec8878b8ae7c74
GitHub-Pull-Request: golang/go#47129
Reviewed-on: https://go-review.googlesource.com/c/go/+/333909
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>

2 years ago[dev.typeparams] cmd/compile: fix escape printout bugs for -G=3
Dan Scales [Wed, 14 Jul 2021 05:21:54 +0000 (22:21 -0700)]
[dev.typeparams] cmd/compile: fix escape printout bugs for -G=3

Call SetPos() in g.expr() so it is available for any new nodes.

Print out the actual type for a composite literal in exprFmt() if
available, else use Ntype if available. Seems generally useful, since
the type name is always more useful than just 'composite literal'.

Fixes a bunch of cases that are excluded in run.go for -G=3.

Change-Id: I40b9bba88027ea4f36d419e3989e7f14891bea04
Reviewed-on: https://go-review.googlesource.com/c/go/+/334609
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2 years ago[dev.typeparams] go/types: export the Config.GoVersion field
Rob Findley [Wed, 14 Jul 2021 18:19:36 +0000 (14:19 -0400)]
[dev.typeparams] go/types: export the Config.GoVersion field

Export the types.Config.GoVersion field, so that users can specify a
language compatibility version for go/types to enforce.

Updates #46648

Change-Id: I9e00122925faf0006cfb08c3f2d022619d5d54d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/334533
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agocmd/go: change link in error message from /wiki to /doc.
Bryan C. Mills [Fri, 2 Jul 2021 20:41:22 +0000 (16:41 -0400)]
cmd/go: change link in error message from /wiki to /doc.

The /doc link is currently a redirect (CL 334389),
but I plan to update it soon with a more detailed guide.

Updates #36460

Change-Id: I9e4a47ad0c8bcb7361cfa3e5b9d07ad241b13ba6
Reviewed-on: https://go-review.googlesource.com/c/go/+/332573
Trust: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 years ago[dev.typeparams] cmd/compile: record more typ/fun info for dictionaries in unified IR
Matthew Dempsky [Tue, 13 Jul 2021 16:09:32 +0000 (09:09 -0700)]
[dev.typeparams] cmd/compile: record more typ/fun info for dictionaries in unified IR

Records whether a derived type is needed at run-time as well as
instantiated functions that rely on derived types (and thus need
sub-dictionaries).

Change-Id: I2f2036976bfce5b3b4372fba88b4116dafa7e6b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/334349
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2 years ago[dev.typeparams] cmd/compile: handle objStub earlier in reader
Matthew Dempsky [Tue, 13 Jul 2021 20:25:16 +0000 (13:25 -0700)]
[dev.typeparams] cmd/compile: handle objStub earlier in reader

There's no point in reading the object dictionary for a stub
declaration. Only the package that contains the full object definition
will contain an object dictionary.

Change-Id: I458b77d20745105bf46190ef552312bdb5ca4d06
Reviewed-on: https://go-review.googlesource.com/c/go/+/334409
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2 years agocmd/go: remove a duplicated word from 'go help mod graph'
Bryan C. Mills [Tue, 13 Jul 2021 21:25:26 +0000 (17:25 -0400)]
cmd/go: remove a duplicated word from 'go help mod graph'

For #46366

Change-Id: Ie9735027a3c4c0f4a604df30ca4d64dcdc62b45a
Reviewed-on: https://go-review.googlesource.com/c/go/+/334375
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

2 years ago[dev.typeparams] cmd/compile/internal/types2: move methods on *Named into named.go...
Robert Griesemer [Fri, 9 Jul 2021 23:02:45 +0000 (16:02 -0700)]
[dev.typeparams] cmd/compile/internal/types2: move methods on *Named into named.go (cleanup)

No other code changes except for an additional comment.

Change-Id: Ica3cea446c6c88f4f81a86d77b289a0b54b1e76f
Reviewed-on: https://go-review.googlesource.com/c/go/+/333671
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: use InstantiateLazy to create instance...
Robert Griesemer [Fri, 9 Jul 2021 22:04:15 +0000 (15:04 -0700)]
[dev.typeparams] cmd/compile/internal/types2: use InstantiateLazy to create instance types (cleanup)

This change concentrates the creation is lazily instantiated types
in one place (InstantiateLazy). This should also make it easier to
replace the implementation of lazily instantiated types (e.g. getting
rid of instance types).

Change-Id: I452c463219b466ce79f227c44fb67b79d428842a
Reviewed-on: https://go-review.googlesource.com/c/go/+/333669
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: move instantiation code to instantiate...
Robert Griesemer [Fri, 9 Jul 2021 20:15:46 +0000 (13:15 -0700)]
[dev.typeparams] cmd/compile/internal/types2: move instantiation code to instantiate.go (cleanup)

No code changes besides moving the two functions and updating a
couple of file comments.

Change-Id: I13a6a78b6e8c132c20c7f81a329f31d5edab0453
Reviewed-on: https://go-review.googlesource.com/c/go/+/333589
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: replace types2.Instantiate with Checker...
Robert Griesemer [Fri, 9 Jul 2021 20:02:24 +0000 (13:02 -0700)]
[dev.typeparams] cmd/compile/internal/types2: replace types2.Instantiate with Checker.Instantiate

Allow Checker.Instantiate to work with a nil *Checker receiver
(for now). This opens the door to passing in a *Checker at all
times.

Also, added a verify flag to Instantiate, InstantiateLazy, and
instance, to be able to control if constraint satisfaction should
be checked or not.

Removed types2.Instantiate.

For #47103.

Change-Id: Ie00ce41b3e50a0fc4341e013922e5f874276d282
Reviewed-on: https://go-review.googlesource.com/c/go/+/333569
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2 years agocrypto/tls: test key type when casting
Roland Shoemaker [Wed, 9 Jun 2021 18:31:27 +0000 (11:31 -0700)]
crypto/tls: test key type when casting

When casting the certificate public key in generateClientKeyExchange,
check the type is appropriate. This prevents a panic when a server
agrees to a RSA based key exchange, but then sends an ECDSA (or
other) certificate.

Fixes #47143
Fixes CVE-2021-34558

Thanks to Imre Rad for reporting this issue.

Change-Id: Iabccacca6052769a605cccefa1216a9f7b7f6aea
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1116723
Reviewed-by: Filippo Valsorda <valsorda@google.com>
Reviewed-by: Katie Hockman <katiehockman@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/334031
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2 years agodoc/go1.17: editing pass over the "Compiler" section
Austin Clements [Fri, 9 Jul 2021 20:22:32 +0000 (16:22 -0400)]
doc/go1.17: editing pass over the "Compiler" section

Change-Id: I08c082f548daa7011a8dc42769371329684c90e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/333609
Trust: Austin Clements <austin@google.com>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
2 years ago[dev.typeparams] Add optional sub-dict entry for typeparam bound calls
Dan Scales [Sat, 3 Jul 2021 00:51:20 +0000 (17:51 -0700)]
[dev.typeparams] Add optional sub-dict entry for typeparam bound calls

In the case that a generic function/method f does a method call on a
type param allowed by its bound, an instantiation of f may do a direct
method call of a concrete type or a method call defined on a generic
type, depending on whether the passed type in a concrete type or an
instantiated type with the appropriate method defined. See the test case
boundmethod.go added to this change.

In order to keep the dictionary format the same for all instantiations
of a generic function/method, I decided to have an optional
sub-dictionary entry for "bounds" calls. At the point that we are
creating the actual dictionary, we can then fill in the needed
sub-dictionary, if the type arg is an instantiated type, or a zeroed
dictionary entry, if type arg is not instantiated and the method will be
on a concrete type.

In order to implement this, I now fill in n.Selection for "bounds"
method calls in generic functions as well. Also, I need to calculate
n.Selection correctly during import for the case where it is now set -
method calls on generic types, and bounds calls on typeparams.

With this change, the dictionaries/sub-dictionaries are correct for
absdiff.go. The new test boundmethod.go illustrates the case where the
bound sub-dict entry is not used for a dictionary for stringify[myint],
but is used for a dictionary for stringify[StringInt[myint]].

Change-Id: Ie2bcb971b7019a9f1da68c97eb03da2333327457
Reviewed-on: https://go-review.googlesource.com/c/go/+/333456
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>

2 years ago[dev.typeparams] cmd/compile: slightly more incremental unified typecheck
Matthew Dempsky [Sat, 10 Jul 2021 02:47:45 +0000 (19:47 -0700)]
[dev.typeparams] cmd/compile: slightly more incremental unified typecheck

This CL pushes the typecheck.Expr calls further down to the IR
construction points. It turns out we don't really care about
typecheck.AssignExpr, because it's only used to distinguish whether
ir.BlankNode is allowed. We can avoid that issue by just skipping the
call to typecheck.Expr for blank nodes.

Similarly, for typecheck.Callee, only two details matter: (1) don't
report errors for builtin functions (which aren't allowed outside of
callee contexts); and (2) method-value selector expressions need to
have Op ODOTMETH/ODOTINTER rather than OMETHVALUE. The first can be
handled by simply skipping typecheck on Names (as with ir.BlankNode,
we don't need to typecheck these). The second currently requires
adding a 'callee bool' parameter to disambiguate the context.

The other option would be for exprCall to reset the fun's Op from
OMETHVALUE to OXDOT and let typecheck handle it a second time. But I
anticipate needing to add extra logic in the exprSelector case which
would be harder to undo, so this seems somewhat better.

Change-Id: I1a8dfb6af04265ab466fd7f4cb6ee8b479e92282
Reviewed-on: https://go-review.googlesource.com/c/go/+/333769
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Matthew Dempsky <mdempsky@google.com>

2 years ago[dev.typeparams] cmd/compile: more incremental typecheck for unified IR
Matthew Dempsky [Sat, 10 Jul 2021 00:47:15 +0000 (17:47 -0700)]
[dev.typeparams] cmd/compile: more incremental typecheck for unified IR

CL 332469 changed the unified IR reader to incrementally typecheck
each statement as they're read/constructed. This CL goes further to
incrementally typecheck each expression.

While here, this CL reorganizes a few things to make this go more
smoothly. In particular, it renames expr to expr0 and adds a new expr
wrapper that applies typecheck.Expr; gets rid of exprTypeSwitchguard
by moving that logic into switchStmt; and splits exprConvert out from
exprCall, which simplifies the logic for typechecking the calleee
expression somewhat.

Change-Id: I6289de9388dc94a947971f4b7213aafeb2faa5dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/333730
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2 years ago[dev.typeparams] cmd/compile: report functions declared in Go and assembly
Matthew Dempsky [Thu, 8 Jul 2021 06:32:49 +0000 (23:32 -0700)]
[dev.typeparams] cmd/compile: report functions declared in Go and assembly

This CL reuses the symabi wrapper information to warn when a function
is defined both in Go (i.e., has a function declaration with a body)
and in assembly (i.e., has a TEXT instruction).

This will eventually produce a linker error anyway, but we can provide
a slightly nicer error message earlier.

Change-Id: Ia107f813343c0b10f4cd1013e7c72e67149ee52e
Reviewed-on: https://go-review.googlesource.com/c/go/+/333454
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years ago[dev.typeparams] internal/buildcfg: allow regabiwrappers on all GOARCH
Matthew Dempsky [Fri, 9 Jul 2021 18:15:23 +0000 (11:15 -0700)]
[dev.typeparams] internal/buildcfg: allow regabiwrappers on all GOARCH

There's nothing GOARCH-specific about ABI wrappers, so allow enabling
them on all architectures.

For unified IR, I want to have a testing mode where we add dictionary
parameters even to non-generic functions, as a way to help stress test
that they're handled correctly. This requires callers to know to
supply the appropriate dictionary arguments when calling them. Calls
generated by the Go compiler know to do this, but calls written in
assembly won't.

Reusing the regabi wrappers is a convenient choke-point for inserting
dictionary arguments for assembly calls.

Change-Id: Ic2c06b7626730289c5405829b61653d1daec430b
Reviewed-on: https://go-review.googlesource.com/c/go/+/333453
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years agoruntime/pprof: call runtime.GC twice in memory profile test
Michael Anthony Knyszek [Fri, 9 Jul 2021 17:34:07 +0000 (17:34 +0000)]
runtime/pprof: call runtime.GC twice in memory profile test

This change fixes #46500 by working around #45315 which may cause freed
objects to get missed in the heap profile published for the test.

By calling runtime.GC one more time this change ensures that all freed
objects are accounted for.

Fixes #46500.

Change-Id: Iedcd0b37dbaffa688b0ff8631a8b79f7a1169634
Reviewed-on: https://go-review.googlesource.com/c/go/+/333549
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: recursive substitution must terminate...
Robert Griesemer [Fri, 9 Jul 2021 02:57:24 +0000 (19:57 -0700)]
[dev.typeparams] cmd/compile/internal/types2: recursive substitution must terminate (bug fix)

When types2.Instantiate is called externally, no *Checker is provided and
substitution doesn't have access to Checker.typMap; and instantiation of
recursive generic types leads to an infinite recursion in subst.

There was a local subster.cache but it was only set and never used.
Replaced subster.cache with subster.typMap, which is set to the global
Checker.typMap if available, and set to a local map otherwise. This
prevents such infinite recursions. Added a simple test.

More generally, because we don't have a global type map for external
instantiations, instantiating the same type twice, independently but
with the same type arguments, will result in two different types. This
is not correct. We need to provide some form of context for external
instantiations (which means the importers). This is a separate but
related issue which is not yet addressed (filed #47103).

Change-Id: I541556c677db54f7396fd0c88c7467894dfcf2e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/333383
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: use scope numbers to identify local...
Robert Griesemer [Thu, 8 Jul 2021 04:38:49 +0000 (21:38 -0700)]
[dev.typeparams] cmd/compile/internal/types2: use scope numbers to identify local types

Rather than using a local types' position information, use the type
name's scope numbers to uniquely identify the type from others with
the same name.

We use scope numbers rather than indices (with number-1 == index)
to preserve the invariant that the zero value for a scope is a ready
to use empty scope.

Using scope numbers turned out to be fairly simple after all and
provides a reasonably stable identification which will make debugging
simpler. A scope number series may be a bit longer than a unique ID for
each type name but local types should be reasonably rare.

Also did a minor cleanup in universe.go to ensure Named.orig is set up
correctly (there's still an open TODO but with a work-around).

Change-Id: I73935fa9bd960809fd5c95fe8b8a535c313cfc8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/333192
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

2 years ago[dev.typeparams] cmd/compile: report mismatch between types because of //go:notinheap
Dan Scales [Thu, 8 Jul 2021 19:07:01 +0000 (12:07 -0700)]
[dev.typeparams] cmd/compile:  report mismatch between types because of //go:notinheap

types2 currently ignores pragmas, so it does not catch a conversion
error when converting a pointer to a type which is NOT marked notinheap
to a pointer to a convertible type, but which is marked notinheap.

So, we specifically check for this error in transformConv() and report
it during noder2.

Change-Id: I6e9c9ee29f53fa5e490c1ac8306e2191db59eeb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/333369
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>

2 years ago[dev.typeparams] all: merge master (296ddf2) into dev.typeparams
Matthew Dempsky [Thu, 8 Jul 2021 20:04:25 +0000 (13:04 -0700)]
[dev.typeparams] all: merge master (296ddf2) into dev.typeparams

Conflicts:

- src/runtime/runtime2.go

  On master, CL 317191 fixed the mentions of gc/reflect.go in comments
  to reflectdata/reflect.go; but on dev.typeparams, CL 325921 fixed
  that the same comment to reflect that deferstruct actually ended up
  in ssagen/ssa.go.

Merge List:

+ 2021-07-08 296ddf2a93 net: filter bad names from Lookup functions instead of hard failing
+ 2021-07-08 ce76298ee7 Update oudated comment
+ 2021-07-08 2ca44fe221 doc/go1.17: linkify time.UnixMilli and time.UnixMicro
+ 2021-07-07 5c59e11f5e cmd/compile: remove special-casing of blank in types.sconv{,2}
+ 2021-07-07 b003a8b1ae cmd/compile: optimize types.sconv
+ 2021-07-07 11f5df2d67 cmd/compile: extract pkgqual from symfmt
+ 2021-07-07 991fd381d5 cmd/go: don't lock .mod and .sum files for read in overlay
+ 2021-07-07 186a3bb4b0 cmd/go/internal/modfetch/codehost: skip hg tests if no hg binary is present
+ 2021-07-07 00c00558e1 cmd/go/internal/modload: remove unused functions
+ 2021-07-07 f264879f74 cmd/go/internal/modload: fix an apparent typo in the AutoRoot comment
+ 2021-07-07 c96833e5ba doc: remove stale comment about arm64 port

Change-Id: I849046b6d8f7421f60323549f3f763ef418bf9e7

2 years ago[dev.typeparams] cmd/compile: cleanup ABI utils tests
Matthew Dempsky [Wed, 7 Jul 2021 23:15:53 +0000 (16:15 -0700)]
[dev.typeparams] cmd/compile: cleanup ABI utils tests

This CL cleans a few minor nits with the ABI utils tests that are now
necessary because of cleanups that happened on master:

1. Initialize types.LocalPkg; this needs to be set for selector names
to be handled correctly.

2. In TestABIUtilsInterfaces, switch to using an exported identifier,
so it doesn't need to be package qualified.

3. While here, change the method result type from "untyped string" to
just "string". Constants are the only declared object that can ever
have an untyped type.

Change-Id: Iabed46594361a516317a1c2d20c3d59bdb519844
Reviewed-on: https://go-review.googlesource.com/c/go/+/333189
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2 years ago[dev.typeparams] cmd/compile: fix bunch of -G=3 bugs for test cases in test/typeparam...
Dan Scales [Wed, 7 Jul 2021 18:49:57 +0000 (11:49 -0700)]
[dev.typeparams] cmd/compile: fix bunch of -G=3 bugs for test cases in test/typeparams/mdempsky

1.go, 12.go: similar to calculating type sizes, we delay computing
instantiations during import until we get up to a top-level type, in
order to make sure recursive types are complete. But we should always
delay calculating sizes when we delay instantiating types, since
otherwise we may try to calculate the size of an incomplete type. So,
needed to add Defer/ResumeCheckSize in (*importReader).typ where we also
defer instantiations. (iimport.go)

2.go: when doing type substition, we have to handle named, parameterized
basic types i.e. the type has a type parameter even though the
underlying type is a basic type that doesn't depend on the parameter.
(subr.go)

3.go: for go 1.18, we allow arbitrary types in interfaces. We had
already allowed union types and tilde types, but didn't allow regular
non-interface types in Go 1.17 for compatibility.  Just skip an error
in the case of 1.18. (size.go)

5.go: types2 and types1 differ in how they print out interfaces. types1
puts a space between "interface" and "{", types2 does not. So, since
some typenames come from types2 and some from types1, we need to remove
the space when printing out type arguments. (iimport.go/subr.go)

9.go: in subst.node(), we were missing the KeyExpr case where a node has
no type. The assertion is just there, to make sure we understand all the
cases where there is no type to translate. We could just remove the
whole error check. (stencil.go)

13.go: in subst.node(), missed handling the case where a method
expression is immediate called (which of course, is quite unusual, since
then there's no real reason to have used the method expression syntax in
that case). Just needed to add ir.OMETHEXPR in the OCALL switch
statement.  (stencil.go)

Change-Id: I202cbe9541dfafe740e3b84b44982d6181738ea0
Reviewed-on: https://go-review.googlesource.com/c/go/+/333165
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2 years agonet: filter bad names from Lookup functions instead of hard failing
Roland Shoemaker [Fri, 2 Jul 2021 17:25:49 +0000 (10:25 -0700)]
net: filter bad names from Lookup functions instead of hard failing

Instead of hard failing on a single bad record, filter the bad records
and return anything valid. This only applies to the methods which can
return multiple records, LookupMX, LookupNS, LookupSRV, and LookupAddr.

When bad results are filtered out, also return an error, indicating
that this filtering has happened.

Updates #46241
Fixes #46979

Change-Id: I6493e0002beaf89f5a9795333a93605abd30d171
Reviewed-on: https://go-review.googlesource.com/c/go/+/332549
Trust: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2 years agoUpdate oudated comment
makdon [Mon, 17 May 2021 16:27:11 +0000 (16:27 +0000)]
Update oudated comment

Update comment cause gc/select.go has been moved to walk/select.go and gc/reflect.go has been moved to reflectdata/reflect.go

Change-Id: I6894527e1e9dbca50ace92a51bf942f9495ce88c
GitHub-Last-Rev: 6d6a4471440403218b68ba32d4038ca41eae2901
GitHub-Pull-Request: golang/go#45976
Reviewed-on: https://go-review.googlesource.com/c/go/+/317191
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Michael Pratt <mpratt@google.com>

2 years agodoc/go1.17: linkify time.UnixMilli and time.UnixMicro
Tobias Klauser [Mon, 5 Jul 2021 08:35:53 +0000 (10:35 +0200)]
doc/go1.17: linkify time.UnixMilli and time.UnixMicro

Change-Id: I8503c4649fc42670f13d981f98af480467d6a3e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/332829
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2 years ago[dev.typeparams] cmd/compile/internal/types2: don't permit method calls on ptr to...
Robert Griesemer [Sat, 3 Jul 2021 01:12:02 +0000 (18:12 -0700)]
[dev.typeparams] cmd/compile/internal/types2: don't permit method calls on ptr to type parameter receivers

Simplify the implementation of asInterface while at it.

For #47031.

Change-Id: Ie7d4fbbab898d961ed3c0b7772ba9604641be13f
Reviewed-on: https://go-review.googlesource.com/c/go/+/332609
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: replace optype() with under() in variou...
Robert Griesemer [Fri, 2 Jul 2021 23:54:14 +0000 (16:54 -0700)]
[dev.typeparams] cmd/compile/internal/types2: replace optype() with under() in various cases (cleanup)

This makes the behavior for type parameter operands explicit
in those cases.

Change-Id: I38438af67de4432f1a691dc4947e4576445f031b
Reviewed-on: https://go-review.googlesource.com/c/go/+/332555
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: clean up index expr implementation...
Robert Griesemer [Fri, 2 Jul 2021 22:41:28 +0000 (15:41 -0700)]
[dev.typeparams] cmd/compile/internal/types2: clean up index expr implementation for type parameters

This makes the implementation match the intended spec behavior:

Given an index expression a[x] where a is a type parameter, the
index expression is valid if the constraint for a satisfies the
following criteria:

- Either all types in the constraint type set are maps, or none
  of them are.

- If the (type set) types are maps, they must all have the same
  key type. (This may be too strict, perhaps it's sufficient to
  ensure assignability, but we can always relax that later.)

- All (type set) types must have the same element types.

- If there are any arrays, a constant index must be in range for
  the shortest array.

Change-Id: I8c094c11e6fc9496c293871ccf93e3814c881e6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/332553
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile/internal/types2: disallow "free" type parameter as RHS...
Robert Griesemer [Fri, 2 Jul 2021 05:10:01 +0000 (22:10 -0700)]
[dev.typeparams] cmd/compile/internal/types2: disallow "free" type parameter as RHS of a type declaration

For #45639.

Change-Id: I20e331b04f464db81e916af75f70ec8ae73eb989
Reviewed-on: https://go-review.googlesource.com/c/go/+/332411
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[dev.typeparams] cmd/compile: fix bug with types2.Instantiate with interface type...
Dan Scales [Wed, 7 Jul 2021 19:03:41 +0000 (12:03 -0700)]
[dev.typeparams] cmd/compile: fix bug with types2.Instantiate with interface type param

types2.subst has an assertion that check is non-nil, but which breaks
Instantiate() with an interface type param (used when re-importing
instatiated type to types2). But this check was added when Instantiate()
was added, and things seem to work fine when the assertion is removed.

Fixes test/typeparam/mdempsky/7.go.

Change-Id: I4980f0b202a0b310a3c91a7a87f97576f54911de
Reviewed-on: https://go-review.googlesource.com/c/go/+/333155
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>

2 years ago[dev.typeparams] cmd/compile: move def of comparable to end of predeclared slices
Dan Scales [Wed, 7 Jul 2021 21:42:26 +0000 (14:42 -0700)]
[dev.typeparams] cmd/compile: move def of comparable to end of predeclared slices

This avoids changing the export ABI.

Change-Id: I58950c1f4c21859d91d66d352b88e8c0972b5b8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/333164
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>