]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
2 years ago[release-branch.go1.18] go1.18.1 go1.18.1
Dmitri Shuralyov [Tue, 12 Apr 2022 14:54:22 +0000 (10:54 -0400)]
[release-branch.go1.18] go1.18.1

Change-Id: If2b91acf7fb4a55cded985d6f2a2ab058c1b7bd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/399818
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2 years ago[release-branch.go1.18] encoding/pem: fix stack overflow in Decode
Julie Qiu [Tue, 1 Mar 2022 16:19:38 +0000 (10:19 -0600)]
[release-branch.go1.18] encoding/pem: fix stack overflow in Decode

Previously, Decode called decodeError, a recursive function that was
prone to stack overflows when given a large PEM file containing errors.

Credit to Juho Nurminen of Mattermost who reported the error.

Fixes CVE-2022-24675
Updates #51853
Fixes #52037

Change-Id: Iffe768be53c8ddc0036fea0671d290f8f797692c
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1391157
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Filippo Valsorda <valsorda@google.com>
(cherry picked from commit 794ea5e828010e8b68493b2fc6d2963263195a02)
Reviewed-on: https://go-review.googlesource.com/c/go/+/399817
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years ago[release-branch.go1.18] go/types: don't report errors for untyped int shifts on Go...
Robert Findley [Wed, 30 Mar 2022 13:56:13 +0000 (09:56 -0400)]
[release-branch.go1.18] go/types: don't report errors for untyped int shifts on Go < 1.13

CL 337529 introduced upfront type-checking of constant shift operands,
to avoid converting their type to uint (per the spec). However, it
had an oversight in that the checks intended for non-constant operands
still ran after the explicit checking of constant operands. As a
result, there are at least two bugs:
 - When GoVersion is < 1.13, we report spurious errors for untyped
   constant shift operands.
 - When the operand is an untyped float constant, we still convert to
   uint (this was a known bug reported in #47410).

Looking at this now, it seems clear that we can avoid both of these bugs
by simply not running the additional checks in the case of a constant
operand. However, this should be considered with some care, as shifts
are notoriously tricky.

While cherry-picking, the new test file is updated to use the go1_12
package name, following our convention for specifying language version
in the release branch.

Fixes #52032

Change-Id: Ia489cc5470b92a8187d3de0423d05b309daf47bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/396775
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 8a816d5efcc842ae92f0193aa9c1d433bd66ef31)
Reviewed-on: https://go-review.googlesource.com/c/go/+/397680

2 years ago[release-branch.go1.18] go/types, types2: fix overlap test for union termlist
Robert Griesemer [Sat, 2 Apr 2022 00:02:28 +0000 (17:02 -0700)]
[release-branch.go1.18] go/types, types2: fix overlap test for union termlist

Per the spec, "the type sets of all non-interface terms must be
pairwise disjoint (the pairwise intersection of the type sets must
be empty)" in a union.

For the overlap test, the existing implementation casually mixed
syntactic union terms (which may have interface type) with type set
terms (which are normalized/expanded and must not have interface
type). As a consequence, in some cases the overlap test failed.

This change skips terms with interface types in the overlap test.

For this cherry-pick, also rename the files ending in issue51607.go
to issue51607.go2 because the 1.18 branch requires tests containing
generic features to end in .go2.

Fixes #52119.

Change-Id: I8ae9953db31f0a0428389c6a45a6696aa2450219
Reviewed-on: https://go-review.googlesource.com/c/go/+/397695
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/398154

2 years ago[release-branch.go1.18] crypto/elliptic: tolerate zero-padded scalars in generic...
Filippo Valsorda [Thu, 31 Mar 2022 16:31:58 +0000 (12:31 -0400)]
[release-branch.go1.18] crypto/elliptic: tolerate zero-padded scalars in generic P-256

Updates #52075
Fixes #52077
Fixes CVE-2022-28327

Change-Id: I595a7514c9a0aa1b9c76aedfc2307e1124271f27
Reviewed-on: https://go-review.googlesource.com/c/go/+/397137
Trust: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Julie Qiu <julie@golang.org>
2 years ago[release-branch.go1.18] cmd/go: prevent panic in go work use
Filippo Rossi [Mon, 4 Apr 2022 06:25:32 +0000 (06:25 +0000)]
[release-branch.go1.18] cmd/go: prevent panic in go work use

Check if paths passed as arguments are existing directories.

Fixes #52140
Updates #51841

Change-Id: Icfd148627e6f2c4651d6f923a37d413e68c67f6c
GitHub-Last-Rev: 77fffa7635052f11dc93488ee23fd1c895284b4d
GitHub-Pull-Request: golang/go#51845
Reviewed-on: https://go-review.googlesource.com/c/go/+/394154
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/397995
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years ago[release-branch.go1.18] crypto/x509: only disable SHA-1 verification for certificates
Roland Shoemaker [Mon, 21 Mar 2022 18:58:08 +0000 (11:58 -0700)]
[release-branch.go1.18] crypto/x509: only disable SHA-1 verification for certificates

Disable SHA-1 signature verification in Certificate.CheckSignatureFrom,
but not in Certificate.CheckSignature. This allows verification of OCSP
responses and CRLs, which still use SHA-1 signatures, but not on
certificates.

Updates #41682
Fixes #51852

Change-Id: Ia705eb5052e6fc2724fed59248b1c4ef8af6c3fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/394294
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Jordan Liggitt <liggitt@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 35998c010947d3a5a26409fffcb4ed16c3595850)
Reviewed-on: https://go-review.googlesource.com/c/go/+/398074
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years ago[release-branch.go1.18] cmd/go: prevent go work use panic when given a file
John Anthony [Thu, 17 Mar 2022 15:36:52 +0000 (15:36 +0000)]
[release-branch.go1.18] cmd/go: prevent go work use panic when given a file

The current implementation fails to identify that an argument to go work
use is a file when expecting a directory, and panics when attempting to
access it as a directory. This change checks arguments are directories
and generates an error otherwise.

Fixes #51764
Updates #51749

Change-Id: If8f69d233409e93fcf391a8774bace74c031c986
Reviewed-on: https://go-review.googlesource.com/c/go/+/393615
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit a84ef500213ef6c2a0e4bfd82253e9fcd28f1f62)
Reviewed-on: https://go-review.googlesource.com/c/go/+/397994
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years ago[release-branch.go1.18] crypto/x509: fix Certificate.Verify crash
Brad Fitzpatrick [Thu, 17 Mar 2022 16:39:46 +0000 (09:39 -0700)]
[release-branch.go1.18] crypto/x509: fix Certificate.Verify crash

(Primarily from Josh)

Updates #51759
Fixes #51763
Fixes CVE-2022-27536

Co-authored-by: Josh Bleecher Snyder <josharian@gmail.com>
Change-Id: I0a6f2623b57750abd13d5e194b5c6ffa3be6bf72
Reviewed-on: https://go-review.googlesource.com/c/go/+/393655
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 0fca8a8f25cf4636fd980e72ba0bded4230922de)
Reviewed-on: https://go-review.googlesource.com/c/go/+/394655
Trust: Roland Shoemaker <roland@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2 years ago[release-branch.go1.18] go/types, types2: preserve parent scope when substituting...
Robert Findley [Thu, 24 Mar 2022 17:29:03 +0000 (13:29 -0400)]
[release-branch.go1.18] go/types, types2: preserve parent scope when substituting receivers

For #51920
Fixes #52007

Change-Id: I29e44a52dabee5c09e1761f9ec8fb2e8795f8901
Reviewed-on: https://go-review.googlesource.com/c/go/+/395538
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 9b90838712856cad86504a526e566f963f86c04e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/395680

2 years ago[release-branch.go1.18] runtime: make static/dynamic startup detection work with...
Paul E. Murphy [Tue, 22 Mar 2022 16:52:02 +0000 (11:52 -0500)]
[release-branch.go1.18] runtime: make static/dynamic startup detection work with musl on ppc64le

The glibc loader explicitly sets the first doubleword on the stack (R1)
to $0 to indicate it was dynamically loaded.

An ELFv2 ABI compliant loader will set R3/R4 to argc/argv when starting
the process, and R13 to TLS. musl is not compliant. Instead it passes
argc/argv like the kernel, but R3/R4 are in an undefined state and R13
is valid.

With the knowledge above, the startup code can be modified to
dynamically handle all three cases when linked internally.

Fixes #51874

Change-Id: I5de33862c161900d9161817388bbc13a65fdc69c
Reviewed-on: https://go-review.googlesource.com/c/go/+/394654
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Paul Murphy <murp@ibm.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/394794
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

2 years ago[release-branch.go1.18] cmd/compile: replace Type.OrigSym with Type.OrigType
Matthew Dempsky [Mon, 21 Mar 2022 17:06:48 +0000 (10:06 -0700)]
[release-branch.go1.18] cmd/compile: replace Type.OrigSym with Type.OrigType

First law of cmd/compile frontend development: thou shalt not rely on
types.Sym.

This CL replaces Type.OrigSym with Type.OrigType, which semantically
matches what all of the uses within the frontend actually care about,
and avoids using types.Sym, which invariably leads to mistakes because
symbol scoping in the frontend doesn't work how anyone intuitively
expects it to.

Fixes #51855.

Change-Id: I4affe6ee0718103ce5006ab68aa7e1bb0cac6881
Reviewed-on: https://go-review.googlesource.com/c/go/+/394274
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
(cherry picked from commit adae6ec542c3287ffe643093a0f61c9871f4e238)
Reviewed-on: https://go-review.googlesource.com/c/go/+/394296

2 years ago[release-branch.go1.18] all update vendored golang.org/x/tools
Robert Findley [Fri, 1 Apr 2022 14:04:19 +0000 (10:04 -0400)]
[release-branch.go1.18] all update vendored golang.org/x/tools

Update x/tools from internal-branch.go1.18-vendor to pick up the
cherry-picked fix for #51727.

The following commands were used, from the cmd module:
  go get -d golang.org/x/tools@internal-branch.go1.18-vendor
  go mod tidy
  go mod vendor

Fixes #51727

Change-Id: I380a66fee585c8c12f9646de87ffb5e398b4ba80
Reviewed-on: https://go-review.googlesource.com/c/go/+/397476
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2 years ago[release-branch.go1.18] cmd/compile/internal/importer: key tparams by Package instead...
Robert Findley [Mon, 21 Mar 2022 20:08:38 +0000 (16:08 -0400)]
[release-branch.go1.18] cmd/compile/internal/importer: key tparams by Package instead of pkgname

The importer type param index used package name as type parameter key,
causing type parameters to be reused/overwritten if two packages in the
import graph had the same combination of (package name, declaration
name, type parameter name).

Fix this by instead using the *Package in the key.

Note: -G=3 was added to typeparam/issue51836.go, as it is necessary for
1.18 but not for tip.

For #51836
Fixes #51847

Change-Id: I881ceaf3cf7c1ab4e0835962350feb552e79b233
Reviewed-on: https://go-review.googlesource.com/c/go/+/394219
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
(cherry picked from commit fd1b5904ae7cc76eefd94d315f92265da5b81b14)
Reviewed-on: https://go-review.googlesource.com/c/go/+/394854

2 years ago[release-branch.go1.18] cmd/compile: fix panic with nested dead hidden closures
Cuong Manh Le [Mon, 21 Mar 2022 11:49:37 +0000 (18:49 +0700)]
[release-branch.go1.18] cmd/compile: fix panic with nested dead hidden closures

CL 342350 fixed deadcode panic with dead hidden closures. However, a
closure may contains nested dead hidden closures, so we need to mark
them dead as well.

Fixes #51846

Change-Id: Ib54581adfc1bdea60e74d733cd30fd8e783da983
Reviewed-on: https://go-review.googlesource.com/c/go/+/394079
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/394080
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2 years ago[release-branch.go1.18] cmd/go: avoid stamping VCS metadata in test binaries
Bryan C. Mills [Fri, 18 Mar 2022 15:40:34 +0000 (11:40 -0400)]
[release-branch.go1.18] cmd/go: avoid stamping VCS metadata in test binaries

Invoking a VCS tool requires that the VCS tool be installed, and also
adds latency to build commands. Unfortunately, we had been mistakenly
loading VCS metadata for tests of "main" packages.

Users almost never care about versioning for test binaries, because
'go test' runs the test in the source tree and test binaries are only
rarely used outside of 'go test'. So the user already knows exactly
which version the test is built against, because the source code is
right there — it's not worth the overhead to stamp.

Fixes #51767.
Updates #51723.

Change-Id: I96f191c5a765f5183e5e10b6dfb75a0381c99814
Reviewed-on: https://go-review.googlesource.com/c/go/+/393894
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 67f6b8c98715f265f38aff4052356ef6e6b35dfe)
Reviewed-on: https://go-review.googlesource.com/c/go/+/393878
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years ago[release-branch.go1.18] cmd/compile: pointers to notinheap types need their own shape
Keith Randall [Fri, 18 Mar 2022 17:46:15 +0000 (10:46 -0700)]
[release-branch.go1.18] cmd/compile: pointers to notinheap types need their own shape

They should not share a shape with regular pointers. We could coalesce
multiple pointer-to-not-in-heap types, but doesn't seem worth it - just
make them fully stenciled.

Fixes #51741

Change-Id: Ie8158177226fbc46a798e71c51897a82f15153df
Reviewed-on: https://go-review.googlesource.com/c/go/+/393895
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
(cherry picked from commit fcf6afb82dc1e9f80a6260467026adc11d5c9529)
Reviewed-on: https://go-review.googlesource.com/c/go/+/393935

2 years ago[release-branch.go1.18] cmd/link: mark unexported methods for plugins
Cherry Mui [Wed, 16 Mar 2022 17:07:57 +0000 (13:07 -0400)]
[release-branch.go1.18] cmd/link: mark unexported methods for plugins

When plugin is used, we already mark all exported methods
reachable. However, when the plugin and the host program share
a common package, an unexported method could also be reachable
from both the plugin and the host via interfaces. We need to mark
them as well.

Fixes #51737.
Updates #51621.

Change-Id: I1a70d3f96b66b803f2d0ab14d00ed0df276ea500
Reviewed-on: https://go-review.googlesource.com/c/go/+/393365
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
(cherry picked from commit 91631bc7e0131367eb051b581cf34573399ac592)
Reviewed-on: https://go-review.googlesource.com/c/go/+/397483

2 years ago[release-branch.go1.18] cmd/compile: fix wrong dict param when getting dict type
Cuong Manh Le [Sat, 12 Mar 2022 17:04:46 +0000 (00:04 +0700)]
[release-branch.go1.18] cmd/compile: fix wrong dict param when getting dict type

CL 338129 added getDictionaryType to get the dictionary type from the
specified dict param, but still using the one in info.dictParam, which
is wrong.

Fixes #51669

Change-Id: Ie13460c1e5751c4c5fc44479a44f6eed8b3b06e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/391994
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-on: https://go-review.googlesource.com/c/go/+/392614

2 years ago[release-branch.go1.18] go/types, types2: use correct underlying type in union set...
Robert Griesemer [Mon, 14 Mar 2022 17:45:16 +0000 (10:45 -0700)]
[release-branch.go1.18] go/types, types2: use correct underlying type in union set computation

Fixes #51665.

Change-Id: Ibf415d7e12849b8f50b58d74713613d4e65bc347
Reviewed-on: https://go-review.googlesource.com/c/go/+/392575
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/392577
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years ago[release-branch.go1.18] crypto/x509: skip WSATRY_AGAIN errors when dialing badssl...
Bryan C. Mills [Fri, 1 Apr 2022 15:09:30 +0000 (11:09 -0400)]
[release-branch.go1.18] crypto/x509: skip WSATRY_AGAIN errors when dialing badssl.com subdomains

(Temporarily, until the root cause of the test failure can be
diagnosed and fixed properly.)

For #52094

Change-Id: Iec69e162159f3f0a93135f742aac97cf82c1d96c
Reviewed-on: https://go-review.googlesource.com/c/go/+/397478
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit df89f2ba53aab53356be197c581d142cefc2c6bc)
Reviewed-on: https://go-review.googlesource.com/c/go/+/397594
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years ago[release-branch.go1.18] bytes: restore old Trim/TrimLeft behavior for nil
Ian Lance Taylor [Fri, 18 Mar 2022 19:14:20 +0000 (12:14 -0700)]
[release-branch.go1.18] bytes: restore old Trim/TrimLeft behavior for nil

Keep returning nil for the cases where we historically returned nil,
even though this is slightly different for TrimLeft and TrimRight.

For #51793
Fixes #51796

Change-Id: Ifbdfc6b09d52b8e063cfe6341019f9b2eb8b70e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/393876
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
(cherry picked from commit 32fdad19a246143ae4f194d1b39886d778de1380)
Reviewed-on: https://go-review.googlesource.com/c/go/+/396294
Reviewed-by: Austin Clements <austin@google.com>
2 years ago[release-branch.go1.18] runtime: call testenv.MustHaveCGO in a couple of tests
Ian Lance Taylor [Wed, 16 Mar 2022 04:05:11 +0000 (21:05 -0700)]
[release-branch.go1.18] runtime: call testenv.MustHaveCGO in a couple of tests

For #51695
Fixes #51697

Change-Id: Icfe9d26ecc28a7db9040d50d4661cf9e8245471e
Reviewed-on: https://go-review.googlesource.com/c/go/+/392916
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
(cherry picked from commit 2d32594396b231b39d09ec21d34b22b0270268b5)
Reviewed-on: https://go-review.googlesource.com/c/go/+/393699
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
2 years ago[release-branch.go1.18] go1.18 go1.18
Heschi Kreinick [Tue, 15 Mar 2022 13:30:31 +0000 (09:30 -0400)]
[release-branch.go1.18] go1.18

Change-Id: I81d8267b73c3dbd0d2f76e8c80fa2ae8b6f386df
Reviewed-on: https://go-review.googlesource.com/c/go/+/392894
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2 years ago[release-branch.go1.18] doc: update go_spec.html with latest changes
Dmitri Shuralyov [Mon, 14 Mar 2022 17:49:14 +0000 (13:49 -0400)]
[release-branch.go1.18] doc: update go_spec.html with latest changes

Generated at 2022-03-14 14:50 (EDT) with:

git fetch
git checkout origin/master -- doc/go_spec.html

This includes spec changes up to CL 391754.

Fixes #51532.

Change-Id: I2c23d764ffa33f24647cd2a4060268c1500f6f99
Reviewed-on: https://go-review.googlesource.com/c/go/+/392674
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2 years ago[release-branch.go1.18] cmd/compile: fix re-export closure
Cuong Manh Le [Thu, 10 Mar 2022 16:41:56 +0000 (23:41 +0700)]
[release-branch.go1.18] cmd/compile: fix re-export closure

For hidden closure built during stenciling to implement a function
instantiation, the function may come from other package, not local
package, which causes the ICE for code that re-export the hidden closure
after inlining.

To fix it, use the closure package for export writer when writing out
the closure itself.

Fixes #51423

Change-Id: I23b067ba14e2d602a0fc3b2e99bd9317afbe53ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/391574
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 9743e9b6d8e150639f509fc64e4bc5f24ecce562)
Reviewed-on: https://go-review.googlesource.com/c/go/+/391774
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years ago[release-branch.go1.18] internal/fuzz: minimization should not reduce coverage
Steven Johnstone [Thu, 10 Mar 2022 13:38:00 +0000 (13:38 +0000)]
[release-branch.go1.18] internal/fuzz: minimization should not reduce coverage

Minimization should result in a fuzz input which
includes the same coverage bits as the original
input.

Updates #48326

Change-Id: I6c5f30058b57ccd1a096ad0e9452a4dfbb7d9aab
Reviewed-on: https://go-review.googlesource.com/c/go/+/391454
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 5003ed884a67ee26b4cedbe6f5b1c02bd5eb6630)
Reviewed-on: https://go-review.googlesource.com/c/go/+/391798
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years ago[release-branch.go1.18] internal/fuzz: don't use dirty coverage maps during minimization
Roland Shoemaker [Thu, 10 Mar 2022 20:16:33 +0000 (12:16 -0800)]
[release-branch.go1.18] internal/fuzz: don't use dirty coverage maps during minimization

When minimizing a value, if the value cannot be minimized (i.e. it is
the final value is the same value as was sent for minimization) return
the initial coverage map, rather than the coverageSnapshot, which is
actually the coverage map for the final minimization step and may not
accurately reflect whether the input actually expands the coverage set
or not.

Updates #48326

Change-Id: I01f0eebe5841e808b6799647d2e5fe3aa45cd2e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/391614
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit bd71dee2b4c0a44f9c32e9eb23d990b54ce06bae)
Reviewed-on: https://go-review.googlesource.com/c/go/+/391797
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

2 years ago[release-branch.go1.18] go/types, types2: remove incorrect assertion (don't crash)
Robert Griesemer [Thu, 10 Mar 2022 20:43:10 +0000 (12:43 -0800)]
[release-branch.go1.18] go/types, types2: remove incorrect assertion (don't crash)

The removed assertion was never incorrect, as signatures may
be from methods in interfaces, and (some) interfaces set the
receivers of their methods (so we have a position for error
reporting).

This CL changes the issue below from a release blocker to an
issue for Go 1.19.

For #51593.

Change-Id: I0c5f2913b397b9ab557ed74a80cc7a715e840412
Reviewed-on: https://go-review.googlesource.com/c/go/+/391615
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 914195c132cbec651aa43c409e8aac2614b53b38)
Reviewed-on: https://go-review.googlesource.com/c/go/+/391796
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[release-branch.go1.18] cmd/compile: fix expression switches using type parameters
Keith Randall [Thu, 10 Mar 2022 18:01:35 +0000 (10:01 -0800)]
[release-branch.go1.18] cmd/compile: fix expression switches using type parameters

Both the thing we're switching on, as well as the cases we're switching for.
Convert anything containing a type parameter to interface{} before the
comparison happens.

Fixes #51522

Change-Id: I97ba9429ed332cb7d4240cb60f46d42226dcfa5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/391594
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
(cherry picked from commit 2e46a0a99768408c90cf4eeda3690831693fd8b2)
Reviewed-on: https://go-review.googlesource.com/c/go/+/391795
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2 years ago[release-branch.go1.18] cmd/compile: fix transform of OEQ/ONE when one arg is a type...
Keith Randall [Thu, 10 Mar 2022 17:02:34 +0000 (09:02 -0800)]
[release-branch.go1.18] cmd/compile: fix transform of OEQ/ONE when one arg is a type param

At this point in stenciling, we have shape types, not raw type parameters.
The code was correct in the other part of this function.

Update #51522

Change-Id: Ife495160a2be5f6af5400363c3efb68dda518b5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/391475
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
(cherry picked from commit 8cf11694abbfbdbd4fe0b2c08511f81b8bfe5017)
Reviewed-on: https://go-review.googlesource.com/c/go/+/391794
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2 years ago[release-branch.go1.18] go/types, types2: pointer base types cannot be type constraints
Robert Griesemer [Wed, 9 Mar 2022 22:27:25 +0000 (14:27 -0800)]
[release-branch.go1.18] go/types, types2: pointer base types cannot be type constraints

Pointer types may appear in expressions *P and we don't know if
we have an indirection (P is a pointer value) or a pointer type
(P is a type) until we type-check P. Don't forget to check that
a type P must be an ordinary (not a constraint) type in this
special case.

Fixes #51578.

Change-Id: If782cc6dd2a602a498574c78c99e40c3b72274a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/391275
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 3a5e3d8173df547d8360a609097fc80f01182db1)
Reviewed-on: https://go-review.googlesource.com/c/go/+/391357
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[release-branch.go1.18] go/types, types2: clarify documentation with respect to gener...
Robert Findley [Wed, 9 Mar 2022 16:35:10 +0000 (11:35 -0500)]
[release-branch.go1.18] go/types, types2: clarify documentation with respect to generic types

Address several areas where documentation was inaccurate or unclear
regarding generic types. Also prefer the use of the word 'generic' over
'parameterized', and add additional documentation for the use of
SetConstraint.

For #49593

Change-Id: Iccac60d1b3e2c45a57a3d03b3c10984293af57dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/391154
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit e189b5e06d4831025758c0b152838fa1a0375525)
Reviewed-on: https://go-review.googlesource.com/c/go/+/391356
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

2 years ago[release-branch.go1.18] go/types, types2: disable field accesses through type parameters
Robert Griesemer [Wed, 9 Mar 2022 18:01:24 +0000 (10:01 -0800)]
[release-branch.go1.18] go/types, types2: disable field accesses through type parameters

This is a feature that is not understood well enough and may have
subtle repercussions impacting future changes. Disable for Go 1.18.

The actual change is trivial: disable a branch through a flag.
The remaining changes are adjustments to tests.

Fixes #51576.

Change-Id: Ib77b038b846711a808315a8889b3904e72367bce
Reviewed-on: https://go-review.googlesource.com/c/go/+/391135
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit b8248fab897da9bee2211a98df1656883ccecd6d)
Reviewed-on: https://go-review.googlesource.com/c/go/+/391355
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[release-branch.go1.18] cmd/go: fix buildvcs when using older git versions
Mark Pulford [Sun, 27 Feb 2022 12:52:22 +0000 (23:22 +1030)]
[release-branch.go1.18] cmd/go: fix buildvcs when using older git versions

Git versions before v2.10.0 do not support --no-show-signature.
Using "-c" allows Git to ignore the configuration option if it does not
exist.

Fixes #51253

Change-Id: I2b1adaca0eb18ae31f2e1119e354ce515b00cfc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/388194
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
(cherry picked from commit 7026eeb8cfdc5801adddaaa678fb6495a998db0e)
Reviewed-on: https://go-review.googlesource.com/c/go/+/391354

2 years ago[release-branch.go1.18] go/printer: don't print unnecesary commas for func type param...
Robert Findley [Tue, 8 Mar 2022 21:43:47 +0000 (16:43 -0500)]
[release-branch.go1.18] go/printer: don't print unnecesary commas for func type param lists

Type parameter lists are not ambiguous for function declarations in the
way that they are ambiguous for type declarations. Avoid printing an
extra comma to disambiguate.

Fixes #51548

Change-Id: I8ca2b21e271982013653b9e220f92ee74f577ba2
Reviewed-on: https://go-review.googlesource.com/c/go/+/390914
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 0add0647d80f8ec794042b4608275830372fe298)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390957
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[release-branch.go1.18] internal/fuzz: fix encoding for out-of-range ints and runes
Bryan C. Mills [Mon, 7 Mar 2022 16:26:18 +0000 (11:26 -0500)]
[release-branch.go1.18] internal/fuzz: fix encoding for out-of-range ints and runes

Also switch float64 NaN encoding to use hexadecimal, and accept
hexadecimal encoding for all other integer types too. (That gives us
the flexibility to change the encodings in either direction in the
future without breaking earlier Go versions.)

Out-of-range runes encoded using "%q" were previously replaced with
the Unicode replacement charecter, losing their values.

Out-of-range ints and uints on 32-bit platforms were previously
rejected. Now they are wrapped instead: an “interesting” case with a
large int or uint found on a 64-bit platform likely remains
interesting on a 32-bit platform, even if the specific values differ.

To verify the above changes, I have made TestMarshalUnmarshal accept
(and check for) arbitrary differences between input and output, and
added tests cases that include values in valid but non-canonical
encodings.

I have also added round-trip fuzz tests in the opposite direction for
most of the types affected by this change, verifying that a marshaled
value unmarshals to the same bitwise value.

Updates #51258
Updates #51526
Fixes #51528

Change-Id: I7727a9d0582d81be0d954529545678a4374e88ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/390424
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 7419bb3ebb8ea2b9b3745cdcbaf747e4dffc52ae)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390816
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years ago[release-branch.go1.18] cmd/compile/internal/types2: more consistently print "check...
thepudds [Tue, 8 Mar 2022 14:51:27 +0000 (14:51 +0000)]
[release-branch.go1.18] cmd/compile/internal/types2: more consistently print "check go.mod" if language version < 1.18

If you attempt to instantiate a generic type or func and run 'go build'
with a language version < 1.18 in the 'go' directive inside the go.mod
file, cmd/compile emits a friendly message that includes the suggestion
to 'check go.mod':

    type instantiation requires go1.18 or later (-lang was set to go1.17; check go.mod)

However, if the code instead only declares a generic type or func
without instantiating, cmd/compile currently emits a less friendly
message:

    type parameters require go1.18 or later

With this CL, the error in that situation becomes:

    type parameter requires go1.18 or later (-lang was set to go1.17; check go.mod)

Within cmd/compile/internal/types2, it already calls check.versionErrorf
in a dozen or so places, including three existing calls to
check.versionErrorf within typeset.go (e.g., for embedding a constraint
interface).

This CL adds two more calls to check.versionErrorf, replacing calls to
check.softErrorf. Both check.versionErrorf and check.softErrorf call
check.err(at, <string>, true) after massaging the string message.

Fixes #51531

Change-Id: If54e179f5952b97701d1dfde4abb08101de07811
GitHub-Last-Rev: b0b7c1346f3a92f70e6cd5ff9ef047f441b09895
GitHub-Pull-Request: golang/go#51536
Reviewed-on: https://go-review.googlesource.com/c/go/+/390578
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
(cherry picked from commit d3070a767bc0ddfdca1f84e2018de1c906b817ca)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390959
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years ago[release-branch.go1.18] go/types, types2: disable inference for type instances
Robert Findley [Thu, 24 Feb 2022 19:18:24 +0000 (14:18 -0500)]
[release-branch.go1.18] go/types, types2: disable inference for type instances

Inference for type instances has dependencies on type-checking order
that can lead to subtle bugs. As explained in #51527, disable it for
1.18.

Fixes #51527

Change-Id: I42795bad30ce53abecfc5a4914599ae5a2041a9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/387934
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 28fab5ef21d8aef72634f9c251fbeb4039dababa)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390576
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[release-branch.go1.18] go/types: document that predicates are undefined on generic...
Robert Findley [Fri, 4 Mar 2022 19:39:43 +0000 (14:39 -0500)]
[release-branch.go1.18] go/types: document that predicates are undefined on generic types

Fixes #50887

Change-Id: I451d66b067badcfb7cf2e2756ea2b062366ac9d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/390039
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 20dd9a42fb80ed4919d79bfb4644c16ab9e09e72)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390575
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[release-branch.go1.18] go/types, types2: record all type instances, even duplicates
Robert Findley [Fri, 4 Mar 2022 23:52:49 +0000 (18:52 -0500)]
[release-branch.go1.18] go/types, types2: record all type instances, even duplicates

Due to instance de-duplication, we were failing to record some type
instances in types.Info.Instances. Fix this by moving the instance
recording out of the resolver.

Fixes #51494

Change-Id: Iddd8989307d95886eedb321efa4ab98cd2b3573a
Reviewed-on: https://go-review.googlesource.com/c/go/+/390041
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 43b09c096a33b8a3cd3477546c445e2c41efcfdf)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390574
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years ago[release-branch.go1.18] go/types, types2: don't crash in selectors referring to the...
Robert Griesemer [Sun, 6 Mar 2022 23:44:42 +0000 (15:44 -0800)]
[release-branch.go1.18] go/types, types2: don't crash in selectors referring to the type being declared

In Checker.typInternal, the SelectorExpr case was the only case that
didn't either set or pass along the incoming def *Named type.

Handle this by passing it along to Checker.selector and report a
cycle if one is detected.

Fixes #51509.

Change-Id: I6c2d46835f225aeb4cb25fe0ae55f6180cef038b
Reviewed-on: https://go-review.googlesource.com/c/go/+/390314
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
(cherry picked from commit 114d5deac2f513a7397ab4c2ee8d2d567a901266)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390423
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years ago[release-branch.go1.18] go/types, types2: correctly include comparable in type set...
Robert Griesemer [Fri, 4 Mar 2022 23:07:17 +0000 (15:07 -0800)]
[release-branch.go1.18] go/types, types2: correctly include comparable in type set intersection

The comparable bit was handled incorrectly. This CL establishes
a clear invariant for a type set's terms and its comparable bit
and correctly uses the bit when computing term intersections.

Relevant changes:

- Introduce a new function intersectTermLists that does the
  correct intersection computation.

Minor:

- Moved the comparable bit after terms in _TypeSet to make it
  clearer that they belong together.

- Simplify and clarify _TypeSet.IsAll predicate.

- Remove the IsTypeSet predicate which was only used for error
  reporting in union.go, and use the existing predicates instead.

- Rename/introduce local variables in computeInterfaceTypeSet
  for consistency and to avoid confusion.

- Update some tests whose output has changed because the comparable
  bit is now only set if we have have the set of all types.
  For instance, for interface{comparable; int} the type set doesn't
  set the comparable bit because the intersection of comparable and
  int is just int; etc.

- Add many more comments to make the code clearer.

Fixes #51472.

Change-Id: I8a5661eb1693a41a17ce5f70d7e10774301f38ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/390025
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 7dc6c5ec34ca6780e8eac1760116ff69d0c27d7a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390419
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

2 years ago[release-branch.go1.18] internal/fuzz: fix TestUnmarshalMarshal on MIPS
Roland Shoemaker [Sat, 5 Mar 2022 16:47:33 +0000 (08:47 -0800)]
[release-branch.go1.18] internal/fuzz: fix TestUnmarshalMarshal on MIPS

Previous value used in the float32 roundtrip used float32(math.NaN())-1
which caused the quiet/signal bit to flip, which seemed to break the
test on MIPS platforms. Instead switch to using float32(math.NaN())+1,
which preserves the bit and makes the test happy.

Possibly related to #37455
Fixes #51258

Change-Id: Ia85c649e89a5d02027c0ec197f0ff318aa819c19
Reviewed-on: https://go-review.googlesource.com/c/go/+/390214
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 63bd6f68e6cbb237b46a99775103758afaee370a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390418
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

2 years ago[release-branch.go1.18] internal/fuzz: handle Inf/NaN float values
Roland Shoemaker [Mon, 28 Feb 2022 13:42:11 +0000 (05:42 -0800)]
[release-branch.go1.18] internal/fuzz: handle Inf/NaN float values

Fixes #51258

Change-Id: I3c8b785ac912d66e1a6e2179625e6903032b8330
Reviewed-on: https://go-review.googlesource.com/c/go/+/388354
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 2b8aa2b734721487bb718ee5fb6080f51b57efd9)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390095
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

2 years ago[release-branch.go1.18] syscall: remove TestRlimit
Ian Lance Taylor [Fri, 4 Mar 2022 18:03:32 +0000 (10:03 -0800)]
[release-branch.go1.18] syscall: remove TestRlimit

It's more trouble than it's worth. New code should be using x/sys/unix
anyhow.

Fixes #40564
Fixes #51479

Change-Id: I1c0e13f494380c1565e98359f088af9f52790b79
Reviewed-on: https://go-review.googlesource.com/c/go/+/390020
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 1e122e3894bd12407b0043ab25c2a5f665b3f6e5)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390022
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years ago[release-branch.go1.18] cmd/go: add links to workspaces reference and tutorial to...
Michael Matloob [Thu, 3 Mar 2022 21:18:31 +0000 (16:18 -0500)]
[release-branch.go1.18] cmd/go: add links to workspaces reference and tutorial to go help work

For #45713

Change-Id: Ia2901cbfc5deb52503e74fcf9dff26a56ec582c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/389297
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 1eb1f621da20d7c93ac0312e59c08afbde4d9f56)
Reviewed-on: https://go-review.googlesource.com/c/go/+/389914
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

2 years ago[release-branch.go1.18] cmd/go: error out of 'go work use' if no directories are...
Bryan C. Mills [Thu, 3 Mar 2022 20:13:11 +0000 (15:13 -0500)]
[release-branch.go1.18] cmd/go: error out of 'go work use' if no directories are given

Otherwise, the behavior of 'go work use -r' (without arguments)
may be surprising.

For #51448.

Change-Id: I50cf1339591720ec5bd333146b89c9944ce420d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/389855
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 4f8094386c3c015f6b6f3efc3a002d188433d388)
Reviewed-on: https://go-review.googlesource.com/c/go/+/389299
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

2 years ago[release-branch.go1.18] cmd/go: make paths consistent between 'go work init' and...
Bryan C. Mills [Thu, 3 Mar 2022 20:07:15 +0000 (15:07 -0500)]
[release-branch.go1.18] cmd/go: make paths consistent between 'go work init' and 'go work use'

Fixes #51448

Change-Id: I86719b55037c377eb82154e169d8a9bbae20b77c
Reviewed-on: https://go-review.googlesource.com/c/go/+/389854
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
(cherry picked from commit 87a345ca3849a68de13f29bdc7628f2943734946)
Reviewed-on: https://go-review.googlesource.com/c/go/+/389298
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

2 years ago[release-branch.go1.18] runtime: count spill slot for frame size at finalizer call
Cherry Mui [Thu, 3 Mar 2022 01:16:54 +0000 (20:16 -0500)]
[release-branch.go1.18] runtime: count spill slot for frame size at finalizer call

The finalizer is called using reflectcall. When register ABI is
used, the finalizer's argument is passed in register(s). But the
frame size calculation does not include the spill slot. When the
argument actually spills, it may clobber the caller's stack frame.
This CL fixes it.

Fixes #51457.

Change-Id: Ibcc7507c518ba65c1c5a7759e5cab0ae3fc7efce
Reviewed-on: https://go-review.googlesource.com/c/go/+/389574
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
(cherry picked from commit 58804ea67a28c1d8e37ed548b685bc0c09638886)
Reviewed-on: https://go-review.googlesource.com/c/go/+/388995
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

2 years ago[release-branch.go1.18] go/types, types2: fix scoping for iteration variables declare...
Robert Griesemer [Thu, 3 Mar 2022 02:38:55 +0000 (18:38 -0800)]
[release-branch.go1.18] go/types, types2: fix scoping for iteration variables declared by range clause

Also correct scope position for such variables.
Adjusted some comments.

Fixes #51437.

Change-Id: Ic49a1459469c8b2c7bc24fe546795f7d56c67cb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/389594
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
(cherry picked from commit d3fe4e193e387f250ba53a80f669eac465b1641d)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390018
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[release-branch.go1.18] cmd/go: ignore the workspace when running a package at a...
Bryan C. Mills [Wed, 2 Mar 2022 22:14:55 +0000 (17:14 -0500)]
[release-branch.go1.18] cmd/go: ignore the workspace when running a package at a specified version

Fixes #51390

Change-Id: I805e66809b2aafb48f7040dee72910dd7d6c1396
Reviewed-on: https://go-review.googlesource.com/c/go/+/388917
Trust: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
(cherry picked from commit 86b5f6a7be707b9d84108df6f459c7e84bf9dbac)
Reviewed-on: https://go-review.googlesource.com/c/go/+/389575
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

2 years ago[release-branch.go1.18] cmd/compile: don't include instantiating types in type hash
Keith Randall [Wed, 2 Mar 2022 23:08:23 +0000 (15:08 -0800)]
[release-branch.go1.18] cmd/compile: don't include instantiating types in type hash

This CL is a bit overkill, but it is pretty safe for 1.18. We'll
want to revisit for 1.19 so we can avoid the hash collisions between
types, e.g. G[int] and G[float64], that will cause some slowdowns
(but not incorrect behavior). Thanks Cherry for the simple idea.

Fixes #51250

Change-Id: I68130e09ba68e7cc35687bc623f63547bc552867
Reviewed-on: https://go-review.googlesource.com/c/go/+/389474
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit d3672054fb58d5eaa241f15fa9d7fb9d61e9ac05)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390017
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2 years ago[release-branch.go1.18] go/types, types2: clarify a comment and add an extra test
Robert Griesemer [Mon, 28 Feb 2022 05:08:29 +0000 (21:08 -0800)]
[release-branch.go1.18] go/types, types2: clarify a comment and add an extra test

Confirm that the current implementation of core type unification
looks correct and update the respective comment. Add an extra test.

Fixes #51376.

Change-Id: I6a603a4baeee2ede5bb4a1d60766204a808936d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/388294
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 6da16b6ad5787a043fc9978d2d009934e3b2e165)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390016
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[release-branch.go1.18] go/types, types2: correctly consider ~ (tilde) in constraint...
Robert Griesemer [Fri, 25 Feb 2022 06:11:40 +0000 (22:11 -0800)]
[release-branch.go1.18] go/types, types2: correctly consider ~ (tilde) in constraint type inference

When doing constraint type inference, we must consider whether the
constraint's core type is precise (no tilde) or imprecise (tilde,
or not a single specific type). In the latter case, we cannot infer
an unknown type argument from the (imprecise) core type because there
are infinitely many possible types. For instance, given

        [E ~byte]

if we don't know E, we cannot infer that E must be byte (it could be
myByte, etc.). On the other hand, if we do know the type argument,
say for S in this example:

        [S ~[]E, E any]

we must consider the underlying type of S when matching against ~[]E
because we have a tilde.

Because constraint type inference may infer type arguments that were
not eligible initially (because they were unknown and the core type
is imprecise), we must iterate the process until nothing changes any-
more. For instance, given

        [S ~[]E, M ~map[string]S, E any]

where we initially only know the type argument for M, we must ignore
S (and E) at first. After one iteration of constraint type inference,
S is known at which point we can infer E as well.

The change is large-ish but the actual functional changes are small:

- There's a new method "unknowns" to determine the number of as of yet
  unknown type arguments.

- The adjCoreType function has been adjusted to also return tilde
  and single-type information. This is now conveniently returned
  as (*term, bool), and the function has been renamed to coreTerm.

- The original constraint type inference loop has been adjusted to
  consider tilde information.

- This adjusted original constraint type inference loop has been
  nested in another loop for iteration, together with some minimal
  logic to control termination.

The remaining changes are modifications to tests:

- There's a substantial new test for this issue.

- Several existing test cases were adjusted to accomodate the
  fact that they inferred incorrect types: tildes have been
  removed throughout. Most of these tests are for pathological
  cases.

- A couple of tests were adjusted where there was a difference
  between the go/types and types2 version.

Fixes #51229.

Change-Id: If0bf5fb70ec22913b5a2da89adbf8a27fbc921d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/387977
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
(cherry picked from commit 0807986fe6bf6040bafa9c415ab72e4cc8e519a4)
Reviewed-on: https://go-review.googlesource.com/c/go/+/390015
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years ago[release-branch.go1.18] cmd/compile: use AutogeneratedPos for method value wrapper
Cherry Mui [Tue, 1 Mar 2022 17:02:38 +0000 (12:02 -0500)]
[release-branch.go1.18] cmd/compile: use AutogeneratedPos for method value wrapper

We use AutogeneratedPos for most compiler-generated functions. But
for method value wrappers we currently don't. Instead, we use the
Pos for their (direct) declaration if there is one, otherwise
not set it in methodValueWrapper, which will probably cause it to
inherit from the caller, i.e. the Pos of that method value
expression. If that Pos has inline information, it will cause the
method wrapper to have bogus inline information, which could lead
to infinite loop when printing a stack trace.

Change it to use AutogeneratedPos instead.

Fixes #51401.

Change-Id: I398dfe85f9f875e1fd82dc2f489dab63ada6570d
Reviewed-on: https://go-review.googlesource.com/c/go/+/388794
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
(cherry picked from commit b0db2f00a0d540c3d3f5d14433da2e3e1ad41f9f)
Reviewed-on: https://go-review.googlesource.com/c/go/+/388918
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

2 years ago[release-branch.go1.18] all: merge master (acc5f55) into release-branch.go1.18
Dmitri Shuralyov [Wed, 2 Mar 2022 23:41:18 +0000 (18:41 -0500)]
[release-branch.go1.18] all: merge master (acc5f55) into release-branch.go1.18

Merge List:

+ 2022-02-28 acc5f55bac cmd/go: make work and work_edit script tests version-independent
+ 2022-02-28 f04d5c118c cmd/internal/obj/riscv/testdata/testbranch: add //go:build lines
+ 2022-02-28 9fe3676bc7 all: fix typos
+ 2022-02-28 f9285818b6 go/types, types2: fix string to type parameter conversions
+ 2022-02-28 eb8198d2f6 cmd/compile: deal with constructed types that have shapes in them
+ 2022-02-28 b33592dcfd spec: the -'s possessive suffix is English, not code
+ 2022-02-28 57e3809884 runtime: avoid cgo_unsafe_args for syscall.syscall functions on darwin/arm64
+ 2022-02-28 06a43e4ab6 cmd/compile: fix case for structural types where we should be looking at typeparams
+ 2022-02-28 0907d57abf cmd/compile: emit types of constants which are instantiated generic types
+ 2022-02-28 9c4a8620c8 CONTRIBUTORS: update for the Go 1.18 release
+ 2022-02-28 57dda9795d test: add new test case for 51219 that triggers the types2 issue
+ 2022-02-26 a064a4f29a cmd/compile: ensure dictionary assignment statements are defining statements
+ 2022-02-26 286e3e61aa go/types, types2: report an error for x.sel where x is a built-in
+ 2022-02-25 01e522a973 go/types,types2: revert documentation for Type.Underlying
+ 2022-02-25 26999cfd84 runtime/internal/atomic: set SP delta correctly for 64-bit atomic functions on ARM
+ 2022-02-25 7c694fbad1 go/types, types2: delay receiver type validation
+ 2022-02-25 55e5b03cb3 doc/go1.18: note changes to automatic go.mod and go.sum updates
+ 2022-02-25 6d810241eb doc/go1.18: document minimum Linux kernel version
+ 2022-02-25 b8b3196375 doc/go1.18: document method set limitation for method selectors
+ 2022-02-24 c0840a7c72 go/types, types2: method recv type parameter count must match base type parameter count
+ 2022-02-24 c15527f0b0 go/types, types2: implement adjCoreType using TypeParam.is
+ 2022-02-24 5a9fc946b4 cmd/go: avoid +incompatible major versions if a go.mod file exists in a subdirectory for that version
+ 2022-02-24 4edefe9568 cmd/compile: delay all call transforms if in a generic function
+ 2022-02-24 8c5904f149 doc/go1.18: mention runtime/pprof improvements
+ 2022-02-24 b2dfec100a doc/go1.18: fix typo in AMD64 port section
+ 2022-02-24 78e99761fc go/types, types2: don't crash if comp. literal element type has no core type
+ 2022-02-23 e94f7df957 go/types, types2: generalize cleanup phase after type checking
+ 2022-02-23 163da6feb5 go/types, types2: add "dynamic" flag to comparable predicate
+ 2022-02-23 e534907f65 go/types: delete unnecessary slice construction
+ 2022-02-23 d0c3b01162 doc/go1.18: drop misplaced period
+ 2022-02-22 35170365c8 net: document methods of Buffers
+ 2022-02-22 3140625606 doc/go1.18: correct "go build -asan" HTML tag
+ 2022-02-22 d17b65ff54 crypto/x509, runtime: fix occasional spurious “certificate is expired”
+ 2022-02-21 c9fe126c8b doc/go1.18: fix a few small typos, add a few commas
+ 2022-02-20 851ecea4cc encoding/xml: embedded reference to substruct causes XML marshaller to panic on encoding
+ 2022-02-19 0261fa616a testdata: fix typo in comment
+ 2022-02-19 903e7cc699 doc/go1.18: fix grammar error
+ 2022-02-19 e002cf4df7 strings: fix typo in comment
+ 2022-02-18 61b5c866a9 doc/go1.18: document Go 1.17 bootstrap and //go:build fix
+ 2022-02-18 d27248c52f runtime: save some stack space for racecall on ARM64
+ 2022-02-18 d93cc8cb96 runtime: define racefuncenter and racefuncexit as ABIInternal
+ 2022-02-18 20b177268f reflect: call ABIInternal moveMakeFuncArgPtrs on ARM64
+ 2022-02-18 d35ed09486 cmd/compile: fix importers to deal with recursion through type constraints
+ 2022-02-16 eaf040502b os: eliminate arbitrary sleep in Kill tests

Change-Id: I74352b70d97c6fd4a45aee4e222160ea2a7854ae

2 years agocmd/go: make work and work_edit script tests version-independent
Michael Matloob [Mon, 28 Feb 2022 21:39:28 +0000 (16:39 -0500)]
cmd/go: make work and work_edit script tests version-independent

The work and work_edit script tests ran go work init, which put the
current Go version into the go.work files. Before this change, the tests
used cmp to compare the outputs with a file that contained a literal
"go 1.18" line. Instead, use cmpenv so we can compare with
"go $goversion". (Some of the test cases still compare against files
that contain "go 1.18" lines, but these tests explicitly set the version
to go 1.18 either in the original go.work files or using go work edit.)

Change-Id: Iea2caa7697b5fe5939070558b1664f70130095ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/388514
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2 years agocmd/internal/obj/riscv/testdata/testbranch: add //go:build lines
Tobias Klauser [Mon, 28 Feb 2022 13:34:11 +0000 (14:34 +0100)]
cmd/internal/obj/riscv/testdata/testbranch: add //go:build lines

Change-Id: I95ea33c0aad7d427da99c0ea7d0869f10ed5dd71
Reviewed-on: https://go-review.googlesource.com/c/go/+/388334
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agoall: fix typos
cuishuang [Mon, 28 Feb 2022 12:17:25 +0000 (12:17 +0000)]
all: fix typos

Change-Id: I93ff3d33a5db130dd57a9545456f2961fc3f668b
GitHub-Last-Rev: f95fafc04937a99f82cb992aabb7bac602033d8e
GitHub-Pull-Request: golang/go#51394
Reviewed-on: https://go-review.googlesource.com/c/go/+/388314
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agogo/types, types2: fix string to type parameter conversions
Robert Griesemer [Mon, 28 Feb 2022 02:13:23 +0000 (18:13 -0800)]
go/types, types2: fix string to type parameter conversions

Converting an untyped constant to a type parameter results
in a non-constant value; but the constant must still be
representable by all specific types of the type parameter.

Adjust the special handling for constant-to-type parameter
conversions to also include string-to-[]byte and []rune
conversions, which are handled separately for conversions
to types that are not type parameters because those are not
constant conversions in non-generic code.

Fixes #51386.

Change-Id: I15e5a0fd281efd15af387280cd3dee320a1ac5e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/388254
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agocmd/compile: deal with constructed types that have shapes in them
Dan Scales [Wed, 23 Feb 2022 05:41:43 +0000 (21:41 -0800)]
cmd/compile: deal with constructed types that have shapes in them

We convert type args to shape types inside instantiations. If an
instantiation constructs a compound type based on that shape type and
uses that as a type arg to another generic function being called, then
we have a type arg with a shape type embedded inside of it. In that
case, we need to substitute out those embedded shape types with their
underlying type.

If we don't do this, we may create extra unneeded shape types that
have these other shape types embedded in them. This may lead to
generating extra shape instantiations, and a mismatch between the
instantiations that we used in generating dictionaries and the
instantations that are actually called.

Updates #51303

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

2 years agospec: the -'s possessive suffix is English, not code
Matthew Dempsky [Sun, 27 Feb 2022 05:08:52 +0000 (21:08 -0800)]
spec: the -'s possessive suffix is English, not code

Change-Id: I2debcf926ef116c632c7366646d37de8686b7c9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/388174
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>

2 years agoruntime: avoid cgo_unsafe_args for syscall.syscall functions on darwin/arm64
Cherry Mui [Fri, 18 Feb 2022 18:09:54 +0000 (13:09 -0500)]
runtime: avoid cgo_unsafe_args for syscall.syscall functions on darwin/arm64

Currently, syscall.syscall-like functions are defined as
cgo_unsafe_args, which makes them ABI0, as it takes the address of
the argument area based on ABI0 layout. Those functions are
linkname'd to the syscall package. When compiling the syscall
package, the compiler doesn't know they are ABI0 therefore
generate an ABIInternal call, which will use the wrapper. As some
of the functions (e.g. syscall6) has many arguments, the wrapper
would take a good amount of stack space. And those functions must
be nosplit. This causes nosplit overflow when building with -N -l
and -race.

Avoid that by rewriting the functions to not use cgo_unsafe_args.
Instead, make a struct locally and pass the address of that
struct. This way the functions are ABIInternal and the call will
not use the wrapper.

Fixes #51247.

Change-Id: I76c1ab86b9d28664fa7d5b9c7928fbb2fd8d1417
Reviewed-on: https://go-review.googlesource.com/c/go/+/386719
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agocmd/compile: fix case for structural types where we should be looking at typeparams
Dan Scales [Fri, 25 Feb 2022 22:56:04 +0000 (14:56 -0800)]
cmd/compile: fix case for structural types where we should be looking at typeparams

In getInstantiation, we were not computing tparams correctly for the
case where the receiver of a method was a fully-instantiated type. This
wasn't affecting later parts of the function, since method
instantiations of fully-instantiated types were already being calculated
in an earlier path. But it did give us a non-typeparam when trying to
see if a shape was associated with a type param with a structural type.
The fix is just to get the typeparams associated with the base generic
type. Then we can eliminate a conditional check later in the code.
The tparam parameter of Shapify should always be non-nil

Fixes #51367

Change-Id: I6f95fe603886148b2dad0c581416c51373c85009
Reviewed-on: https://go-review.googlesource.com/c/go/+/388116
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2 years agocmd/compile: emit types of constants which are instantiated generic types
Keith Randall [Sat, 26 Feb 2022 00:06:53 +0000 (16:06 -0800)]
cmd/compile: emit types of constants which are instantiated generic types

Normally types of constants are emitted when the type is defined (an
ODCLTYPE). However, the types of constants where the type is an
instantiated generic type made inside the constant declaration, do not
normally get emitted. But the DWARF processor in the linker wants
to see those types. So we emit them during stenciling.

Fixes #51245

Change-Id: I59f20f1d7b91501c9ac760cf839a354356331fc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/388117
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agoCONTRIBUTORS: update for the Go 1.18 release
Dmitri Shuralyov [Mon, 28 Feb 2022 14:28:47 +0000 (09:28 -0500)]
CONTRIBUTORS: update for the Go 1.18 release

This update was created using the updatecontrib command:

go install golang.org/x/build/cmd/updatecontrib@latest
cd gotip
updatecontrib

With manual changes based on publicly available information
to canonicalize letter case and formatting for a few names.

For #12042.

Change-Id: If08b7e798cff6ec4248011bdadcc524b510aaff7
Reviewed-on: https://go-review.googlesource.com/c/go/+/388394
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Trust: Carlos Amedee <carlos@golang.org>

2 years agotest: add new test case for 51219 that triggers the types2 issue
Dan Scales [Thu, 24 Feb 2022 01:57:09 +0000 (17:57 -0800)]
test: add new test case for 51219 that triggers the types2 issue

The existing test for 51219 didn't actually trigger the types2 issue - I
hadn't been able to minimize the test case yet properly. This new test
case issue51219b.go now does trigger the types2 issue (it's only
slightly different).

Updates #51219

Change-Id: Iaba8144b4702ff4fefec86c899b8acef127b10dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/387814
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agocmd/compile: ensure dictionary assignment statements are defining statements
Keith Randall [Fri, 25 Feb 2022 23:10:24 +0000 (15:10 -0800)]
cmd/compile: ensure dictionary assignment statements are defining statements

The problem in 51355 is that escape analysis decided that the
dictionary variable was captured by reference instead of by value. We
want dictionaries to always be captured by value.

Escape analysis was confused because it saw what it thought was a
reassignment of the dictionary variable. In fact, it was the only
assignment, it just wasn't marked as the defining assignment. Fix
that.

Add an assert to make sure this stays true.

Fixes #51355

Change-Id: Ifd9342455fa107b113f5ff521a94cdbf1b8a7733
Reviewed-on: https://go-review.googlesource.com/c/go/+/388115
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/types, types2: report an error for x.sel where x is a built-in
Robert Griesemer [Fri, 25 Feb 2022 19:10:44 +0000 (11:10 -0800)]
go/types, types2: report an error for x.sel where x is a built-in

In case of a selector expression x.sel where x is a built-in
we didn't report an error because the type of built-ins is
invalid and we surpress errors on operands of invalid types,
assuming that an error has been reported before.

Add a corresponding check for this case.

Review all places where we call Checker.exprOrType to ensure
(invalid) built-ins are reported.

Adjusted position for index error in types2.

Fixes #51360.

Change-Id: I24693819c729994ab79d31de8fa7bd370b3e8469
Reviewed-on: https://go-review.googlesource.com/c/go/+/388054
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types,types2: revert documentation for Type.Underlying
Robert Findley [Fri, 25 Feb 2022 23:20:12 +0000 (18:20 -0500)]
go/types,types2: revert documentation for Type.Underlying

In the dev.typeparams branch, the documentation for Type.Underlying was
updated with commentary about forwarding chains. This aspect of
Underlying should not be exposed to the user. Revert to the
documentation of Go 1.16.

Fixes #51036

Change-Id: I4b73d3908a88606314aab56540cca91c014dc426
Reviewed-on: https://go-review.googlesource.com/c/go/+/388036
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agoruntime/internal/atomic: set SP delta correctly for 64-bit atomic functions on ARM
Cherry Mui [Fri, 25 Feb 2022 04:31:53 +0000 (23:31 -0500)]
runtime/internal/atomic: set SP delta correctly for 64-bit atomic functions on ARM

64-bit atomic functions on ARM have the following structure:
- check if the address is 64-bit aligned, if not, prepare a frame
  and call panicUnaligned
- tail call armXXX or goXXX depending on GOARM

The alignment check calls panicUnaligned after preparing a frame,
so the stack can be unwound. The call never returns, so the SP is
not set back. However, the assembler assigns SP delta following
the instruction stream order, not the control flow. So it leaves
a nonzero SP delta after the check, to the tail call instructions,
which is wrong because when they are executed the SP is not
decremented. This CL fixes this by adding the SP back (the
instruction never executes, just tells the assembler to set the
SP delta back).

Should fix #51353.

Change-Id: I976cb1cfb0e9008b13538765cbc7eea0c19c7130
Reviewed-on: https://go-review.googlesource.com/c/go/+/388014
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agogo/types, types2: delay receiver type validation
Robert Griesemer [Thu, 24 Feb 2022 21:35:16 +0000 (13:35 -0800)]
go/types, types2: delay receiver type validation

Delay validation of receiver type as it may cause premature expansion
of types the receiver type is dependent on. This was actually a TODO.

While the diff looks large-ish, the actual change is small: all the
receiver validation code has been moved inside the delayed function
body, and a couple of comments have been adjusted.

Fixes #51232.
Fixes #51233.

Change-Id: I44edf0ba615996266791724b832d81b9ccb8b435
Reviewed-on: https://go-review.googlesource.com/c/go/+/387918
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agodoc/go1.18: note changes to automatic go.mod and go.sum updates
Bryan C. Mills [Thu, 24 Feb 2022 22:01:14 +0000 (17:01 -0500)]
doc/go1.18: note changes to automatic go.mod and go.sum updates

Fixes #51242
Updates #45551

Change-Id: Iba6e6acd9a94d24e26fcdd125f1022430723ada7
Reviewed-on: https://go-review.googlesource.com/c/go/+/387920
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Bryan Mills <bcmills@google.com>

2 years agodoc/go1.18: document minimum Linux kernel version
Tobias Klauser [Thu, 24 Feb 2022 09:19:54 +0000 (10:19 +0100)]
doc/go1.18: document minimum Linux kernel version

For #45964

Change-Id: Ic66502c50ca328e944c91e710dca6c8dbc168e4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/387855
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agodoc/go1.18: document method set limitation for method selectors
Robert Griesemer [Thu, 24 Feb 2022 23:45:11 +0000 (15:45 -0800)]
doc/go1.18: document method set limitation for method selectors

For #51183.
For #47694.

Change-Id: If47ae074c3cd9f73b2e7f6408749d9a7d56bd8d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/387924
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agogo/types, types2: method recv type parameter count must match base type parameter...
Robert Griesemer [Thu, 24 Feb 2022 05:43:06 +0000 (21:43 -0800)]
go/types, types2: method recv type parameter count must match base type parameter count

Check receiver type parameter count when type checking the method
signature and report a suitable error (don't rely on delayed
instantiation and possibly constraint type inference).

While at it, simplify blank name recoding and type bound rewriting.

Stop-gap measure to avoid crashes in the compiler.

Fixes #51339.
For #51343.

Change-Id: Idbe2d32d69b66573ca973339f8924b349d2bc9cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/387836
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: implement adjCoreType using TypeParam.is
Robert Griesemer [Wed, 23 Feb 2022 00:53:17 +0000 (16:53 -0800)]
go/types, types2: implement adjCoreType using TypeParam.is

TypeParam.is also provides ~ (tilde) information which is needed
to fix #51229. Delete all code related to singleType as it's not
used anymore.

Also, remove TypeParam.hasTerms as it was not used.

For #51229.

Change-Id: Ie49b19d157230beecb17a444d1f17cf24aa4f6ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/387774
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agocmd/go: avoid +incompatible major versions if a go.mod file exists in a subdirectory...
Bryan C. Mills [Wed, 23 Feb 2022 16:55:08 +0000 (11:55 -0500)]
cmd/go: avoid +incompatible major versions if a go.mod file exists in a subdirectory for that version

Previous versions of the 'go' command would reject a pseudo-version
passed to 'go get' if that pseudo-version had a mismatched major
version and lacked a "+incompatible" suffix. However, they would
erroneously accept a version *with* a "+incompatible" suffix even if
the repo contained a vN/go.mod file for the same major version, and
would generate a "+incompatible" pseudo-version or version if the user
requested a tag, branch, or commit hash.

This change uniformly rejects "vN.…" without "+incompatible", and also
avoids resolving to "vN.…+incompatible", when vN/go.mod exists.
To maintain compatibility with existing go.mod files, it still accepts
"vN.…+incompatible" if the version is requested explicitly as such
and the repo root lacks a go.mod file.

Fixes #51324
Updates #36438

Change-Id: I2b16150c73fc2abe4d0a1cd34cb1600635db7139
Reviewed-on: https://go-review.googlesource.com/c/go/+/387675
Trust: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 years agocmd/compile: delay all call transforms if in a generic function
Dan Scales [Mon, 1 Nov 2021 02:45:21 +0000 (19:45 -0700)]
cmd/compile: delay all call transforms if in a generic function

We changed to delaying all transforms of generic functions, since there
are so many complicated situations where type params can be used. We
missed changing so that all Call expressions(not just some) are delayed
if in a generic function. This changes to delaying all transforms on
calls in generic functions. Had to convert Call() to g.callExpr() (so we
can access g.delayTransform()). By always delaying transforms on calls
in generic functions, we actually simplify the code a bit both in
g.CallExpr() and stencil.go.

Fixes #51236

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

2 years agodoc/go1.18: mention runtime/pprof improvements
Felix Geisendörfer [Wed, 23 Feb 2022 09:55:18 +0000 (10:55 +0100)]
doc/go1.18: mention runtime/pprof improvements

For #47694.

Change-Id: Ib49145a58b8388d35267cf4b0caa730d7e436d06
Reviewed-on: https://go-review.googlesource.com/c/go/+/387574
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rhys Hiltner <rhys@justin.tv>
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Bryan Mills <bcmills@google.com>

2 years agodoc/go1.18: fix typo in AMD64 port section
Tobias Klauser [Thu, 24 Feb 2022 09:02:52 +0000 (10:02 +0100)]
doc/go1.18: fix typo in AMD64 port section

Change-Id: I234ae7988fd3c7a41c08e72664f8db811eb23bb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/387854
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2 years agogo/types, types2: don't crash if comp. literal element type has no core type
Robert Griesemer [Wed, 23 Feb 2022 22:26:07 +0000 (14:26 -0800)]
go/types, types2: don't crash if comp. literal element type has no core type

Instead, report a suitable error.

Fixes #51335.

Change-Id: Ifce90cb7487b1e99c6b4221c0d43bacc0c39dca8
Reviewed-on: https://go-review.googlesource.com/c/go/+/387676
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types, types2: generalize cleanup phase after type checking
Robert Griesemer [Tue, 22 Feb 2022 21:06:52 +0000 (13:06 -0800)]
go/types, types2: generalize cleanup phase after type checking

Use a cleanup method and simple registration mechanism
for types that need some final processing before the end
of type checking.

Use cleanup mechanism instead of expandDefTypes mechanism
for *Named types. There is no change in functionality here.

Use cleanup mechanism also for TypeParam and Interface types
to ensure that their check fields are nilled out at the end.

Introduce a simple constructor method for Interface types
to ensure that the cleanup method is always registered.

In go/types, add tracing code to Checker.checkFiles to match
types2.

Minor comment adjustments.

Fixes #51316.
Fixes #51326.

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

2 years agogo/types, types2: add "dynamic" flag to comparable predicate
Robert Griesemer [Sun, 20 Feb 2022 20:58:21 +0000 (12:58 -0800)]
go/types, types2: add "dynamic" flag to comparable predicate

A type implements a comparable interface only if the type
is statically known to be comparable. Specifically, a type
cannot contain (component) interfaces that are not statically
known to be comparable.

This CL adds a flag "dynamic" to the comparable predicate to
control whether interfaces are always (dynamically) comparable.
Set the flag to true when testing for (traditional) Go comparability;
set the flag to false when testing whether a type implements the
comparable interface.

Fixes #51257.

Change-Id: If22bc047ee59337deb2e7844b8f488d67e5c5530
Reviewed-on: https://go-review.googlesource.com/c/go/+/387055
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2 years agogo/types: delete unnecessary slice construction
Robert Findley [Fri, 18 Feb 2022 14:19:47 +0000 (09:19 -0500)]
go/types: delete unnecessary slice construction

CL 374294 made our check for incorrect type parameters constraints
eager, but failed to remove the construction of the bounds slice, which
was no longer used.

Change-Id: Ib8778fba947ef8a8414803e95d72c49b8f75c204
Reviewed-on: https://go-review.googlesource.com/c/go/+/386717
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2 years agodoc/go1.18: drop misplaced period
Michael Pratt [Wed, 23 Feb 2022 17:23:41 +0000 (12:23 -0500)]
doc/go1.18: drop misplaced period

Change-Id: Id29f352c8d2e61672f55294120058b1f585f7aeb
Reviewed-on: https://go-review.googlesource.com/c/go/+/387655
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agonet: document methods of Buffers
Martin Sucha [Tue, 22 Feb 2022 20:51:04 +0000 (21:51 +0100)]
net: document methods of Buffers

There is code in the wild that copies the Buffers slice,
but not the contents.
Let's document explicitly that it is not safe to do so.

Updates #45163

Change-Id: Id45e27b93037d4e9f2bfde2558e7869983b60bcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/387434
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2 years agodoc/go1.18: correct "go build -asan" HTML tag
Cherry Mui [Tue, 22 Feb 2022 17:54:57 +0000 (12:54 -0500)]
doc/go1.18: correct "go build -asan" HTML tag

The tag was "go-mod-vendor", which doesn't match the content.

Also move that section later, so "go mod" sections stay together.

For #47694.

Change-Id: Id4fa7ee0768682a9aadfeb1b2f1d723e7521896b
Reviewed-on: https://go-review.googlesource.com/c/go/+/387354
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agocrypto/x509, runtime: fix occasional spurious “certificate is expired”
Russ Cox [Tue, 22 Feb 2022 14:05:21 +0000 (09:05 -0500)]
crypto/x509, runtime: fix occasional spurious “certificate is expired”

As documented in #51209, we have been seeing a low-rate failure
on macOS builders caused by spurious x509 “certificate is expired” errors.

The root cause is that CFDateCreate takes a float64, but it is being
passed a uintptr instead. That is, we're not even putting CFDateCreate's
argument in the right register during the call. Luckily, having just
computed the argument by calling time.Duration.Seconds, which
returns a float64, most of the time the argument we want is still
in the right floating point register, somewhat accidentally.

The only time the lucky accident doesn't happen is when the goroutine
is rescheduled between calling time.Duration.Seconds and calling
into CFDateCreate *and* the rescheduling smashes the floating point
register, which can happen during various block memory moves,
since the floating point registers are also the SIMD registers.

Passing the float64 through explicitly eliminates the problem.
It is difficult to write a test for this that is suitable for inclusion
in the standard library. We will have to rely on the builders to
start flaking again if somehow this problem is reintroduced.

For future reference, there is a standalone test that used to fail
every few seconds at https://go.dev/play/p/OWfDpxgnW9g.

Fixes #51209.

Change-Id: I8b334a51e41f406b13f37270e9175c64fe6f55ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/387255
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agodoc/go1.18: fix a few small typos, add a few commas
Alberto Donizetti [Sat, 19 Feb 2022 17:13:52 +0000 (18:13 +0100)]
doc/go1.18: fix a few small typos, add a few commas

Updates #47694

Change-Id: I6c1c3698fdd55fe83c756f28776d1d26dba0a9df
Reviewed-on: https://go-review.googlesource.com/c/go/+/386974
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agoencoding/xml: embedded reference to substruct causes XML marshaller to panic on encoding
hopehook [Sun, 13 Feb 2022 14:03:56 +0000 (22:03 +0800)]
encoding/xml: embedded reference to substruct causes XML marshaller to panic on encoding

When encoding a xml attribute is zero value (IsValid == false), we need
a `continue` to jump over the attribute. If not, followed marshalAttr
function will panic.

Fixes: #50164
Change-Id: I42e064558e7becfbf47728b14cbf5c7afa1e8798
Reviewed-on: https://go-review.googlesource.com/c/go/+/385514
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agotestdata: fix typo in comment
hopehook [Sat, 19 Feb 2022 04:33:16 +0000 (12:33 +0800)]
testdata: fix typo in comment

Change-Id: If3d5884d9f3f32606c510af5597529b832a8f4a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/386934
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

2 years agodoc/go1.18: fix grammar error
Nick Sherron [Fri, 18 Feb 2022 22:43:31 +0000 (22:43 +0000)]
doc/go1.18: fix grammar error

sed 's/the/that/g'

Change-Id: I3f539817b055d54b0ec99346555ac91b756d9ed6
GitHub-Last-Rev: 2e7df1c3462d4b3a17e9a05ff178341f4ee369b0
GitHub-Pull-Request: golang/go#51267
Reviewed-on: https://go-review.googlesource.com/c/go/+/386854
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

2 years agostrings: fix typo in comment
George Looshch [Sat, 15 Jan 2022 19:43:05 +0000 (21:43 +0200)]
strings: fix typo in comment

Remove unnecessary whitespace in noescape comment

Fixes #50634

Change-Id: I1c8d16c020b05678577d349470fac7e7ab8a10b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/378815
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

2 years agodoc/go1.18: document Go 1.17 bootstrap and //go:build fix
Russ Cox [Fri, 18 Feb 2022 19:51:58 +0000 (14:51 -0500)]
doc/go1.18: document Go 1.17 bootstrap and //go:build fix

For #44505 and #41184.

Change-Id: I9503292dace1aa60de167ca5807bf131554465b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/386774
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2 years agoruntime: save some stack space for racecall on ARM64
Cherry Mui [Fri, 18 Feb 2022 00:45:50 +0000 (19:45 -0500)]
runtime: save some stack space for racecall on ARM64

To avoid nosplit overflow in -race -N -l build.

For #51247.

Change-Id: I48426bbd4adefd18eaf26ed51b4113c6a28305b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/386716
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agoruntime: define racefuncenter and racefuncexit as ABIInternal
Cherry Mui [Fri, 18 Feb 2022 00:43:49 +0000 (19:43 -0500)]
runtime: define racefuncenter and racefuncexit as ABIInternal

They are called from compiler instrumented code as ABIInternal.
Define them as ABIInternal to avoid the wrappers and save some
stack space, to avoid nosplit overflow in -race -N -l build.

For #51247.

Change-Id: Iadad7d6da8ac03780a7b02b03b004c52d34e020a
Reviewed-on: https://go-review.googlesource.com/c/go/+/386715
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agoreflect: call ABIInternal moveMakeFuncArgPtrs on ARM64
Cherry Mui [Fri, 18 Feb 2022 00:28:19 +0000 (19:28 -0500)]
reflect: call ABIInternal moveMakeFuncArgPtrs on ARM64

Save some stack space, to avoid nosplit overflow in
-race -N -l build.

For #51247.

Change-Id: I7357d6227f816a612a64f55f7ca1b1384e9268e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/386714
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agocmd/compile: fix importers to deal with recursion through type constraints
Dan Scales [Thu, 17 Feb 2022 04:11:52 +0000 (20:11 -0800)]
cmd/compile: fix importers to deal with recursion through type constraints

The code for issue #51219 reveals bugs in the types1 and types2
importers that can occur for recursive types that are recursive through
the type constraint.

The crash in the issue is caused by the types1 bug, which leads to the
production of a type1 type which is incomplete and improperly has the
HasTParam flag set. The bug in the types1 importer is that we were not
deferring type instantiations when reading the type parameters, but we
need to do that exactly to correctly handle recursion through the type
constraint. So, the fix is to move the start of the deferrals (in the
'U' section of doDecl in typecheck/iimport.go) above the code that reads
the type params.

Once that bug is fixed, the test still crashes due to a related types2
importer issues. The problem is that t.SetConstraint(c) requires c to be
fully constructed (have its underlying type set). Since that may not be
done yet in the 'U' case in (*importReader).obj() in
importer/iimport.go, we need to defer the call to SetConstraint() in
that case, until we are done importing all the types.

I added a test case with recursion through a type constraint that causes
a problem that is fixed by the types1 importer change, though the error
is not the same as in the issue. I added more types in the test case
(which try to imitate the issue types more closely) the types2 bug, but
wasn't able to cause it yet with the smaller test case.

Fixes #51219

Change-Id: I85d860c98c09dddc37f76ce87a78a6015ec6fd20
Reviewed-on: https://go-review.googlesource.com/c/go/+/386335
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>