]> Cypherpunks repositories - gostls13.git/log
gostls13.git
3 years agomisc/cgo/test: remove unnecessary forward declaration
Bryan C. Mills [Mon, 22 Nov 2021 14:50:47 +0000 (09:50 -0500)]
misc/cgo/test: remove unnecessary forward declaration

This test otherwise fails to build on windows/arm64 as of CL 364774
due to a warning (promoted to an error) about a mismatched dllexport
attribute. Fortunately, it seems not to need the forward-declared
function in this file anyway.

Updates #49633
Updates #49721

Change-Id: Ia4698b85077d0718a55d2cc667a7950f1d8e50ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/366075
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/go: report a helpful error when there are no modules in workspace
Michael Matloob [Fri, 19 Nov 2021 21:09:52 +0000 (16:09 -0500)]
cmd/go: report a helpful error when there are no modules in workspace

The current error message that no go.mod files were found is not
helpful, especially when a go.mod file exists in the current directory.

Fixes #49594

Change-Id: I750475ce8654eeb3e0a2857d5a2de1a9c6ede415
Reviewed-on: https://go-review.googlesource.com/c/go/+/365319
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agoRevert "cmd/go: temporarily skip TestScript/test_fuzz_minimize"
Bryan C. Mills [Mon, 22 Nov 2021 14:37:19 +0000 (14:37 +0000)]
Revert "cmd/go: temporarily skip TestScript/test_fuzz_minimize"

This reverts CL 365315.

Reason for revert: test may have been fixed by intervening changes.

Change-Id: I110948d53a789527edf471f1637eadbd98a1fc5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/366074
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
3 years agocmd/go: fix go work sync when there are zero workspace modules
Michael Matloob [Thu, 18 Nov 2021 19:48:26 +0000 (14:48 -0500)]
cmd/go: fix go work sync when there are zero workspace modules

go work sync panics when there are no workspace modules. This is
because the code that set the pruning mode only did so with modules
present. This change changes pruningForGoVersion to properly return
workspace pruning in workspace mode to prevent that. Another weird
scenario can happen when there are no workspace modules, but the
command-line-arguments module is created by default. Check for that
when iterating over the workspace modules to avoid trying to find the
nonexistant go.mod file for that modules.

Fixes #49591

Change-Id: Iee8bc92a8aaf9c440f88fe4f9ca908a8d461cd36
Reviewed-on: https://go-review.googlesource.com/c/go/+/365234
Trust: Michael Matloob <matloob@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agoA+C: add Zhou Guangyuan (individual CLA)
zhouguangyuan [Fri, 19 Nov 2021 17:49:32 +0000 (01:49 +0800)]
A+C: add Zhou Guangyuan (individual CLA)

Change-Id: I34b966b2f3de93a1d086be3dea5ebc6c60cf1eec
Reviewed-on: https://go-review.googlesource.com/c/go/+/365754
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
3 years agogo/types,types2: use allInteger to check type for shifted operand
zhouguangyuan [Sun, 21 Nov 2021 13:06:27 +0000 (21:06 +0800)]
go/types,types2: use allInteger to check type for shifted operand

Fixes: #49705
Change-Id: I35a1c5f29b57f3facc5e89d33a8dec88e0ff4afa
Reviewed-on: https://go-review.googlesource.com/c/go/+/365895
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

3 years agospec: add section on the structure of interfaces
Robert Griesemer [Fri, 19 Nov 2021 01:52:24 +0000 (17:52 -0800)]
spec: add section on the structure of interfaces

This change introduces the notion of a structural interface
and its corresponding structural type.

Change-Id: Ib5442dfd04cb5950b4467428cae51849f8922272
Reviewed-on: https://go-review.googlesource.com/c/go/+/365474
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agospec: add type parameter types
Robert Griesemer [Thu, 18 Nov 2021 23:33:19 +0000 (15:33 -0800)]
spec: add type parameter types

- add section on type parameters
- added two sections on the scope of type parameters
- expanded general section on types accordingly
- introduced the notion of a named type which will
  help in simplifying various rules (subsequent CLs)

Change-Id: I49c1ed7d6d4f951d751f0a3ca5dfb637e49829f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/365414
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agospec: add type parameter lists
Robert Griesemer [Thu, 18 Nov 2021 20:16:39 +0000 (12:16 -0800)]
spec: add type parameter lists

Change-Id: I29e9188a0fa1326c2755a9b86aeb47feaa8019be
Reviewed-on: https://go-review.googlesource.com/c/go/+/365274
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agotest: fix -G=0 mode for longtest builder
Dan Scales [Sat, 20 Nov 2021 01:52:41 +0000 (17:52 -0800)]
test: fix -G=0 mode for longtest builder

For -G=3 for test using 'any'.

Change-Id: Ia37ee944a38be4f4330e62ad187f10f2d42e41bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/365839
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
3 years agocmd/compile: ensure generic function is loaded when it needs to be re-exported
Dan Scales [Fri, 19 Nov 2021 20:13:04 +0000 (12:13 -0800)]
cmd/compile: ensure generic function is loaded when it needs to be re-exported

In the case where we need to re-export a generic function/method from
another package in the export data of the current package, make sure it
is loaded before trying to write it out.

Fixed #49667

Change-Id: I177754bb762689f34cf5c8ad246d43f1cdbbf195
Reviewed-on: https://go-review.googlesource.com/c/go/+/365837
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agoruntime/cgo: add example of Handle with void* parameter
Alan Donovan [Wed, 17 Nov 2021 17:54:22 +0000 (12:54 -0500)]
runtime/cgo: add example of Handle with void* parameter

Fixes #49633

Change-Id: I12ca350f7dd6bfc8753a4a169f29b89ef219b035
Reviewed-on: https://go-review.googlesource.com/c/go/+/364774
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>

3 years agocmd/link: exit early when -d is used on libc platforms
Cherry Mui [Fri, 19 Nov 2021 21:36:03 +0000 (16:36 -0500)]
cmd/link: exit early when -d is used on libc platforms

On platforms where we use libc for syscalls, we dynamically link
with libc and therefore dynamic linking cannot be disabled. Exit
early when -d is specified.

Update #42459.

Change-Id: I05abfe111df723b5ee512ceafef734e3804dd0a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/365658
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/compile: handle `any` as alias like `byte` and `rune`
Matthew Dempsky [Thu, 18 Nov 2021 21:43:04 +0000 (13:43 -0800)]
cmd/compile: handle `any` as alias like `byte` and `rune`

`types.Types[types.TINTER]` is already used for `interface{}`, so we
can conveniently just extend the existing logic that substitutes
`byte` and `rune` with `uint8` and `int32` to also substitute `any`.

Fixes #49665.

Change-Id: I1ab1954699934150aab899b35037d5611c8ca47e
Reviewed-on: https://go-review.googlesource.com/c/go/+/365354
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agonet: simplify deadline fluctuation tests
Bryan C. Mills [Thu, 18 Nov 2021 21:07:13 +0000 (16:07 -0500)]
net: simplify deadline fluctuation tests

These tests were checking for fairly narrow timing windows, but were
running in parallel and heavily dependent on timer and goroutine
scheduling. This change eliminates unnecessary goroutines, runs the
tests sequentially (dramatically shortening the timeouts to reduce the
penalty of doing so), and uses timestamp comparison instead of
background timers to hopefully gain some robustness from monotonic
timestamps.

Many of the other tests from this package would benefit from similar
simplifications, which we can apply if and when we notice flaky
failures or want to improve the latency of running the test.

Fixes #36108

Change-Id: I17d8af7d2eefb1ec14fe0d9d891142a39599a562
Reviewed-on: https://go-review.googlesource.com/c/go/+/365334
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocrypto/x509/internal/macos: use APIs available on ios
Roland Shoemaker [Tue, 16 Nov 2021 20:33:03 +0000 (12:33 -0800)]
crypto/x509/internal/macos: use APIs available on ios

Use SecCertificateCopyData instead of SecItemExport, which is only
available on macOS.

Updates #49616

Change-Id: Ieda33894930d23c6dab6112ee18120f8a440083b
Reviewed-on: https://go-review.googlesource.com/c/go/+/364554
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
3 years agodoc/go1.18: mention register ABI on ARM64 and PPC64
Cherry Mui [Fri, 12 Nov 2021 18:10:30 +0000 (13:10 -0500)]
doc/go1.18: mention register ABI on ARM64 and PPC64

For #47694.

Change-Id: Ide378f4a34587027c3d84fed2126c5b9bd8f7287
Reviewed-on: https://go-review.googlesource.com/c/go/+/363694
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
3 years ago[go] doc: document speedups to Trim[|Left|Right]
Jeremy Faller [Fri, 19 Nov 2021 20:11:22 +0000 (15:11 -0500)]
[go] doc: document speedups to Trim[|Left|Right]

CL: #332771

Updates: #47694
Change-Id: I8c729084b7a8745ec73f87ef3c469edbd596ddb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/365318
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
3 years ago[go] doc: add new bufio functionality
Jeremy Faller [Fri, 19 Nov 2021 18:56:24 +0000 (13:56 -0500)]
[go] doc: add new bufio functionality

cl/345570
cl/345569

Updates: #47694
Change-Id: I170af16d5fc9f022d3d29ed0772cfc3d02b8bbcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/365317
Trust: Jeremy Faller <jeremy@golang.org>
Run-TryBot: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
3 years agocmd/go: temporarily skip TestScript/test_fuzz_minimize
Bryan C. Mills [Fri, 19 Nov 2021 17:51:25 +0000 (12:51 -0500)]
cmd/go: temporarily skip TestScript/test_fuzz_minimize

This test is failing on the longtest builders.
Adding a skip temporarily until it can be diagnosed and fixed.

For #49685

Change-Id: I0ceaf009f5029d1ad6f667f7cfee1f1605737bf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/365315
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
3 years agointernal/fuzz: fix chunk swap mutator
Roland Shoemaker [Thu, 18 Nov 2021 19:40:48 +0000 (11:40 -0800)]
internal/fuzz: fix chunk swap mutator

When swapping two chunks of bytes in a slice, don't pick chunks which
extend beyond the end of the slice. Also don't pick chunks which
intersect with each other.

Fixes #49047

Change-Id: I070eb1888d05ae849ec6122d01c40c45e602019f
Reviewed-on: https://go-review.googlesource.com/c/go/+/365175
Trust: Roland Shoemaker <roland@golang.org>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Katie Hockman <katie@golang.org>
3 years agointernal/fuzz: compute correct number of mutations
Roland Shoemaker [Thu, 18 Nov 2021 21:30:55 +0000 (13:30 -0800)]
internal/fuzz: compute correct number of mutations

When reconstructing inputs, we miscalculated the number of mutations
that needed to be applied. If the count%chainedMutation == 0 we would
apply 0 mutations, when we should actually be applying chainedMutation
mutations, due to how count is incremented.

Fixes #49047

Change-Id: I76773bff0afd6dfd40deafc317be095da995ecc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/365294
Trust: Roland Shoemaker <roland@golang.org>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: don't run ComputeAddrTaken on imported generic functions
Dan Scales [Thu, 18 Nov 2021 18:52:35 +0000 (10:52 -0800)]
cmd/compile: don't run ComputeAddrTaken on imported generic functions

It causes a crash because of the unexpected XDOT operation. It's not
needed, since we will run ComputeAddrTaken() on function instantiations
after stenciling. And it's not always correct, since we may not be able
to distinguish between a array and a slice, if a type is dependent on a
type param.

However, we do need to call ComputeAddrTaken on instantiations created
during inlining, since that is after the main ComputeAddrTaken pass.

Fixes #49659

Change-Id: I0bb610cf11f14e4aa9068f6ca2a012337b069c79
Reviewed-on: https://go-review.googlesource.com/c/go/+/365214
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/go/internal/test: add dep from test pkg build to real pkg build
Ian Lance Taylor [Thu, 18 Nov 2021 20:14:24 +0000 (12:14 -0800)]
cmd/go/internal/test: add dep from test pkg build to real pkg build

If we have to build a test package, and if the full set of packages
being tested imports the regular package somewhere, then make building
the test package depend on building the regular package.  That way if
the regular package fails to build we only report the error once.

Fixes #44624

Change-Id: Ic7d66d8fec9c4688d369153a4b21194989f8def3
Reviewed-on: https://go-review.googlesource.com/c/go/+/365215
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agospec: various clarifications/fixes for method sets and interfaces
Robert Griesemer [Thu, 18 Nov 2021 18:02:08 +0000 (10:02 -0800)]
spec: various clarifications/fixes for method sets and interfaces

- fixed a typo in the method set section
- express in the syntax that ~T denotes an underlying type
- be more precise when talking about types vs type terms
- refer to "unions" rather than "union expressions"
- make it clear in the spec title that this is WIP

Change-Id: I9b2c4b1f77bc50dd574ed6893bedd40529c320fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/365154
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agonet: optimize ctxDone usage
Mikhail Faraponov [Tue, 16 Nov 2021 19:41:43 +0000 (19:41 +0000)]
net: optimize ctxDone usage

Change-Id: I6db6fcf0ebe36da77af062114b5264405f15fee8
GitHub-Last-Rev: 80a97262bb220bb3958c94016eadf385cdf915e8
GitHub-Pull-Request: golang/go#49620
Reviewed-on: https://go-review.googlesource.com/c/go/+/364514
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>

3 years agogo/types: add test for imported constraints pre-1.18
Robert Findley [Thu, 18 Nov 2021 01:22:32 +0000 (20:22 -0500)]
go/types: add test for imported constraints pre-1.18

This is a port of CL 363834 from types2 to go/types.

Change-Id: I32583ead4bce626e0761f4c327678050404a15c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/364937
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: use "implements" rather than "satisfies" in error messages
Robert Findley [Thu, 18 Nov 2021 01:17:55 +0000 (20:17 -0500)]
go/types: use "implements" rather than "satisfies" in error messages

This is a port of CL 363839 from types2 to go/types.

Change-Id: I9efe412a6a602fd55170d1ee89c8e1513037c926
Reviewed-on: https://go-review.googlesource.com/c/go/+/364936
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: remove unneccesary tests in implements and lookup
Robert Findley [Thu, 18 Nov 2021 01:04:14 +0000 (20:04 -0500)]
go/types: remove unneccesary tests in implements and lookup

This is a port of CL 363838 from types2 to go/types.

Change-Id: I03f4da86ea38209a73f567cc5d84e7afd08883ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/364935
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: implement Checker.implements
Robert Findley [Thu, 18 Nov 2021 01:01:16 +0000 (20:01 -0500)]
go/types: implement Checker.implements

This is a port of CL 363837 from types2 to go/types. As usual, test
error messages had to be repositioned on the operand.

Change-Id: I2b53fae7aa30f9147f8d05f75b0ab252338320bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/364934
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/link: relocate dwarf examiner helper to separate package
Than McIntosh [Fri, 12 Nov 2021 18:20:07 +0000 (13:20 -0500)]
cmd/link: relocate dwarf examiner helper to separate package

The linker DWARF test includes an "examiner" helper type (with
associated methods) that is used to help linker DWARF tests read DWARF
info in a higher level and more structured way than just raw
debug/dwarf operations. This patch extracts out "examiner" and
relocates it to a separate package, so that it can be used in other
package tests as well, if need be.

Change-Id: Iec66061e2719ee698c12d8fa17b11698442b336d
Reviewed-on: https://go-review.googlesource.com/c/go/+/364036
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agospec: generalize method sets and interface types to type sets
Robert Griesemer [Wed, 10 Nov 2021 17:44:58 +0000 (09:44 -0800)]
spec: generalize method sets and interface types to type sets

This is the first of several CLs that update the existing
Go 1.17 spec for type parameters.

This CL updates the section on method sets and interface types.
It also adds "any", "comparable" to the list of predeclared
identifiers.

Change-Id: I0ce25dc02791c33150c0d949528512610faf3eab
Reviewed-on: https://go-review.googlesource.com/c/go/+/362999
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agotest: make issue8606b test more robust
Keith Randall [Thu, 18 Nov 2021 00:12:43 +0000 (16:12 -0800)]
test: make issue8606b test more robust

Use actual unmapped memory instead of small integers to make
pointers that will fault when accessed.

Fixes #49562

Change-Id: I2c60c97cf80494dd962a07d10cfeaff6a00f4f8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/364914
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agogo/types: better position for invalid slice indices error
Robert Findley [Thu, 18 Nov 2021 00:45:49 +0000 (19:45 -0500)]
go/types: better position for invalid slice indices error

This is a port of CL 363671 from types2 to go/types. Also adjust the
error message to match types2 ("invalid" vs "swapped").

Change-Id: I662a73c915814fea14bfcb1ebde0fbf39589f022
Reviewed-on: https://go-review.googlesource.com/c/go/+/364902
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: better position for "3-index slice of string" error
Robert Findley [Thu, 18 Nov 2021 00:37:04 +0000 (19:37 -0500)]
go/types: better position for "3-index slice of string" error

This is a port of CL 363670 from types2 to go/types.

Change-Id: I2ac3a5f86bb4eafddd2854e193083b2b737e29b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/364901
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: move match function to end of file (cleanup)
Robert Findley [Thu, 18 Nov 2021 00:29:13 +0000 (19:29 -0500)]
go/types: move match function to end of file (cleanup)

This is a port of CL 363669 from types2 to go/types.

Change-Id: Id1f375ff5708dab528144e30ce16d24d6fdf7d00
Reviewed-on: https://go-review.googlesource.com/c/go/+/364900
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: allow slicing for operands with []byte|string type sets
Robert Findley [Thu, 18 Nov 2021 00:26:37 +0000 (19:26 -0500)]
go/types: allow slicing for operands with []byte|string type sets

This is a port of CL 363662 from types2 to go/types. An error message
was adjusted to be on the operand in test data.

Change-Id: I4d2d69976f4f05e0d89ba1c6bf8b3e4cf1a82316
Reviewed-on: https://go-review.googlesource.com/c/go/+/364899
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: optimize common case in structuralType
Robert Findley [Thu, 18 Nov 2021 00:22:22 +0000 (19:22 -0500)]
go/types: optimize common case in structuralType

This is a port of CL 363668 from types2 to go/types.

Change-Id: Ic55acb2e27f57c33467cef2f687cd695e092ba6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/364898
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: simplify under() and fix a crash
Robert Findley [Thu, 18 Nov 2021 00:20:52 +0000 (19:20 -0500)]
go/types: simplify under() and fix a crash

This is a port of CL 363665 from types2 to go/types.

Change-Id: I20c4e20ab97f1e4de66a29095dc4a9b160810fe5
Reviewed-on: https://go-review.googlesource.com/c/go/+/364897
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: remove tparamIsIface flag and corresponding dead code
Robert Findley [Thu, 18 Nov 2021 00:14:58 +0000 (19:14 -0500)]
go/types: remove tparamIsIface flag and corresponding dead code

This is a port of CL 363654 from types2 to go/types.

Change-Id: I64041615ccc7f11f2e4ae395b063ec5141ccf2cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/364896
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: remove asNamed
Robert Findley [Thu, 18 Nov 2021 00:04:17 +0000 (19:04 -0500)]
go/types: remove asNamed

This is a port of CL 363441 from types2 to go/types, with an additional
adjustment in methodset.go.

Change-Id: Ia04dcfb70bb9f6af6f45175dee3334dba7b2768e
Reviewed-on: https://go-review.googlesource.com/c/go/+/364895
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: remove a review comment in implicitTypeAndValue
Robert Findley [Wed, 17 Nov 2021 23:56:46 +0000 (18:56 -0500)]
go/types: remove a review comment in implicitTypeAndValue

This is a clean port of CL 363440 from types2 to go/types.

Change-Id: Ibbef41b5b599d5c88f7122670ab87aa5be512c0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/364894
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agoruntime: make faketime more robust against GC
Ian Lance Taylor [Wed, 17 Nov 2021 19:07:44 +0000 (11:07 -0800)]
runtime: make faketime more robust against GC

When using faketime, only run the scavenger for one loop.
It tries to run for 1 ms, but with faketime that calculation fails.

Prohibit write barriers in the faketime write function, in case
the GC wants to print something (e.g., with GODEBUG=gctrace=1).

Fixes #49614

Change-Id: Iab5097fe78b6e0032ea8b493088264dfb25013c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/364757
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/go: skip broken fuzz test
Roland Shoemaker [Wed, 17 Nov 2021 21:03:13 +0000 (13:03 -0800)]
cmd/go: skip broken fuzz test

For #49047

Change-Id: If06ce033f7bfd23d640311f1be261afab8332028
Reviewed-on: https://go-review.googlesource.com/c/go/+/364758
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types: set tparamsIsIface to true
Robert Findley [Wed, 17 Nov 2021 15:42:13 +0000 (10:42 -0500)]
go/types: set tparamsIsIface to true

This is a port of CL 363155 from types2 to go/types.

Change-Id: Ic24f8c88513599c8f4685f0b66d3782ac4e6831a
Reviewed-on: https://go-review.googlesource.com/c/go/+/364717
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: underlying type of a type parameter is its constraint interface
Robert Findley [Wed, 17 Nov 2021 15:39:36 +0000 (10:39 -0500)]
go/types: underlying type of a type parameter is its constraint interface

This is a port of CL 359016 from types2 to go/types. Some of the code
around untyped nil differed (because we have to treat untyped nil
differently in go/types for historical reasons).

Updates #47916

Change-Id: Ifc428ed977bf2f4f84cc831f1a3527156940d7b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/364716
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agoruntime: don't run TestCheckPtr/TestCheckPtr2 in short mode
Ian Lance Taylor [Wed, 17 Nov 2021 17:40:11 +0000 (09:40 -0800)]
runtime: don't run TestCheckPtr/TestCheckPtr2 in short mode

Change-Id: I02c9bea1637c2694a76e7747cb8a2e3562301566
Reviewed-on: https://go-review.googlesource.com/c/go/+/364755
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agogo/types: check for non-negative index in tparamIndex
Robert Findley [Wed, 17 Nov 2021 14:38:16 +0000 (09:38 -0500)]
go/types: check for non-negative index in tparamIndex

There are code paths (particularly error formatting or tracing) that
call tparamIndex before the type parameter is bound. We cannot rely on
the index being non-negative.

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

3 years agogo/types, types2: complete methods on pointer receivers in missingMethod
Robert Findley [Wed, 17 Nov 2021 14:35:57 +0000 (09:35 -0500)]
go/types, types2: complete methods on pointer receivers in missingMethod

We were not calling objDecl on methods on pointer receivers in
missingMethod. This may not have mattered before, but with lazy
completion of instance methods it is necessary.

Fixes #49579

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

3 years agogo/types: match Go 1.17 compiler error messages more closely
Robert Findley [Wed, 17 Nov 2021 00:17:31 +0000 (19:17 -0500)]
go/types: match Go 1.17 compiler error messages more closely

Introduce a new constant compilerErrorMessages, which is set to false
for now, so that we can port types2 error handling more precisely. Use
this to (partially) port CL 363436, excluding issue49005.go, which does
not exist in go/types (it was added in a previous CL related to compiler
error messages, that was not ported). I've also included the bugfix from
CL 364034, so that go/types is not broken at this commit.

In subsequent CLs I'll catch up with error handling locations in types2
that use compiler error messages.

Change-Id: I13fd6c43d61b28e0a7a3b0ae8ba785fb8506fbb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/364379
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agoruntime: don't serialize all builds in test
Ian Lance Taylor [Wed, 17 Nov 2021 06:18:02 +0000 (22:18 -0800)]
runtime: don't serialize all builds in test

Permit a test whose program is already built to run immediately,
rather than waiting for another test to complete its build.

For #44422

Change-Id: I2d1b35d055ee4c4251f4caef3b52dccc82b71a1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/364654
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agointernal/fuzz: limit number of consecutive mutations
Roland Shoemaker [Tue, 16 Nov 2021 01:47:15 +0000 (17:47 -0800)]
internal/fuzz: limit number of consecutive mutations

This makes two changes: (1) mutator.mutate now only applies a single
mutation to the input, and (2) in workerServer.fuzz if, after five
mutations are applied to the input, no new coverage is found the input
is reset to its initial state. This process is repeated until new
coverage is found, or the fuzz call times out.

This results in finding new coverage expanding inputs which have less
divergence from the initial input they were mutated from, which makes
traversing certain types of call graphs significantly more efficient.

Fixes #49601
Fixes #48179
Fixes #47090

Change-Id: I74d18a56ca2669f20192951090b281f58ee0b5dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/364214
Trust: Roland Shoemaker <roland@golang.org>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
3 years agoruntime: make sure to properly park before going to sleep in Windows ConsoleControlHa...
Patrik Nyblom [Tue, 16 Nov 2021 22:35:59 +0000 (14:35 -0800)]
runtime: make sure to properly park before going to sleep in Windows ConsoleControlHandler

This change avoids the program intermittently hanging on windows/arm64 after getting
a signal for which the ConsoleControlHandler can not return.

Fixes #49458

Change-Id: Ie28f0f437c7e0f9634b6b3e29dc6cdebd5d996f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/364556
Trust: Patrik Nyblom <pnyb@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Patrik Nyblom <pnyb@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types: better error for type assertion/switch on type parameter value
Robert Findley [Tue, 16 Nov 2021 16:24:22 +0000 (11:24 -0500)]
go/types: better error for type assertion/switch on type parameter value

This is a port of CL 363439 from types2 to go/types.

Change-Id: Ic71871874345e1d0a4a42703e3673aadd11f2bfc
Reviewed-on: https://go-review.googlesource.com/c/go/+/364378
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/compile: emit definition of 'any' only if generic enabled
Cuong Manh Le [Wed, 17 Nov 2021 03:17:31 +0000 (10:17 +0700)]
cmd/compile: emit definition of 'any' only if generic enabled

CL 364377 emitted definition of 'any' when compiling runtime. But 'any'
is only available when generic enabled. Thus emitting its definition
unconditionally causes the compiler crashes.

Updates #49619

Change-Id: I0888ca1cbc7a7df300310a99a344f170636333f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/364614
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agogo/types: make sure we are safe for nil in underIs
Robert Griesemer [Wed, 17 Nov 2021 01:51:58 +0000 (17:51 -0800)]
go/types: make sure we are safe for nil in underIs

This CL is a clean port CL 363658 from types2 to go/types.

Change-Id: Ie2032f85a9cfca62161c2e629c78f1ecd8c6e4c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/364537
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: return an error from Instantiate on incorrect len(targs)
Robert Griesemer [Tue, 16 Nov 2021 20:20:11 +0000 (12:20 -0800)]
cmd/compile/internal/types2: return an error from Instantiate on incorrect len(targs)

This CL is a clean port of CL 363635 from go/types to types2.

Updates #47916

Change-Id: Ib46758435c31ad9a6a4a63f552503d5afa66b5c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/364534
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: add a test for Context deduplication of hash collisions
Robert Griesemer [Tue, 16 Nov 2021 19:36:09 +0000 (11:36 -0800)]
cmd/compile/internal/types2: add a test for Context deduplication of hash collisions

This CL is a clean port of CL 363517 from go/types to types2,
with the exception that types_test.go was not removed because
it's still needed to set a types2-specific test flag.

Change-Id: I12177866537c0f95f3fa36fa0f4aa02016609ca9
Reviewed-on: https://go-review.googlesource.com/c/go/+/364494
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: rename types.context to types.environment
Robert Griesemer [Tue, 16 Nov 2021 19:27:56 +0000 (11:27 -0800)]
cmd/compile/internal/types2: rename types.context to types.environment

This CL is a clean port of CL 363176 from go/types to types2.

It also includes a minor adjustment to a field access in go/types
to match types2 in that respect.

Change-Id: If33fc7e68372b12d61d06b75dd9f7c0715b57bc1
Reviewed-on: https://go-review.googlesource.com/c/go/+/364474
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: don't set a Config.Context if none is provided
Robert Griesemer [Tue, 16 Nov 2021 19:18:53 +0000 (11:18 -0800)]
cmd/compile/internal/types2: don't set a Config.Context if none is provided

This CL is a clean port of CL 363175 from go/types to types2.

Change-Id: I149789be07c0ca7ddef7bfaa4ea9507778a63775
Reviewed-on: https://go-review.googlesource.com/c/go/+/364454
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: when type hashing, canonicalize interfaces
Robert Griesemer [Tue, 16 Nov 2021 16:39:44 +0000 (08:39 -0800)]
cmd/compile/internal/types2: when type hashing, canonicalize interfaces

This CL is a clean port of CL 363115 from go/types to types2.

Change-Id: Ic2bd9388c57ffa02e75ab136d952e3ab49eb9018
Reviewed-on: https://go-review.googlesource.com/c/go/+/364394
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: when type hashing, use placeholders for type parameters
Robert Griesemer [Tue, 16 Nov 2021 16:31:38 +0000 (08:31 -0800)]
cmd/compile/internal/types2: when type hashing, use placeholders for type parameters

This is a port of CL 363114 from go/types to types2 with a temporary
work-around in tparamIndex to avoid a crash with the unified build
and test/typeparam/setsimp.go.

Change-Id: Id4805385f21c95b461911b246fb47ee278a84ac9
Reviewed-on: https://go-review.googlesource.com/c/go/+/364336
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: deduplicate signatures with the context
Robert Griesemer [Tue, 16 Nov 2021 16:22:53 +0000 (08:22 -0800)]
cmd/compile/internal/types2: deduplicate signatures with the context

This CL is a mostly clean port of CL 362801 from go/types to types2.
It deviates from go/types in some of the testing code because types2
already had made some of the changes.

It also re-introduces some empty lines that got lost in earlier CLs.

Change-Id: I0bebd68f0880fac61631a5d0c323a9f8ce853ac6
Reviewed-on: https://go-review.googlesource.com/c/go/+/364335
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: add a test for argument error unwrapping
Robert Griesemer [Wed, 17 Nov 2021 01:30:47 +0000 (17:30 -0800)]
cmd/compile/internal/types2: add a test for argument error unwrapping

This CL is a clean port of CL 351338 from go/types to types2.

Change-Id: I7fd0e5a447bf51cb359e71731c2f9b95e3960da6
Reviewed-on: https://go-review.googlesource.com/c/go/+/364536
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: tweaks to ArgumentError to be more idiomatic
Robert Griesemer [Wed, 17 Nov 2021 01:02:11 +0000 (17:02 -0800)]
cmd/compile/internal/types2: tweaks to ArgumentError to be more idiomatic

This CL is a clean port of CL 351335 from go/types to types2.

Updates #47916

Change-Id: Idc377fb71d480a51d5e93a348f3a880346011974
Reviewed-on: https://go-review.googlesource.com/c/go/+/364535
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile: emit definition of 'any' when compiling runtime
Than McIntosh [Tue, 16 Nov 2021 23:44:08 +0000 (18:44 -0500)]
cmd/compile: emit definition of 'any' when compiling runtime

Include the predefined type 'any' in the list of other important
predefined types that are emitted when compiling the runtime package
(uintptr, string, etc).

Fixes #49619.

Change-Id: I4a851ba2f302fbc3a425e65daa325c6bf83659da
Reviewed-on: https://go-review.googlesource.com/c/go/+/364377
Trust: Than McIntosh <thanm@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agoruntime: remove defer test log spam
Josh Bleecher Snyder [Tue, 16 Nov 2021 21:01:57 +0000 (13:01 -0800)]
runtime: remove defer test log spam

This appears to be leftover debugging
from CL 356011.

Change-Id: Ieeda0b7e297e0cb943827b28644135e6cad12e3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/364555
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoruntime: check GOAMD64 compatibility after setting up TLS
Keith Randall [Mon, 15 Nov 2021 23:56:39 +0000 (15:56 -0800)]
runtime: check GOAMD64 compatibility after setting up TLS

We need TLS set up to be able to print an error without crashing.

Fixes #49586
Update #45453

Change-Id: I97f0efcd716a8dca614e82ab73f2d855b7277599
Reviewed-on: https://go-review.googlesource.com/c/go/+/364174
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <martin@golang.org>
Trust: Martin Möhrmann <martin@golang.org>
Trust: Keith Randall <khr@golang.org>

3 years agosort: improve sort documentation
jiahua wang [Tue, 21 Sep 2021 23:59:11 +0000 (07:59 +0800)]
sort: improve sort documentation

Fixes #48527

Change-Id: Ib5df0819cbcd5c2e4f03bda841871d237af96b19
Reviewed-on: https://go-review.googlesource.com/c/go/+/351336
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agoos/exec: avoid NewFile on unknown FDs
Michael Pratt [Mon, 15 Nov 2021 18:50:39 +0000 (13:50 -0500)]
os/exec: avoid NewFile on unknown FDs

exec_test.go's init function uses os.NewFile(fd) + f.Stat as a portable
mechanism to determine if an FD is in use.

Unfortunately, the current use is racy: if an unused FD becomes used
between NewFile and f.Close, then we will unintentionally close an FD we
do not use.

We cannot simply drop Close, as the finalizer will close the FD. We
could hold all of the os.Files in a global for the lifetime of the
process, but the need for such a hack is indicative of the larger
problem: we should not create an os.File for an FD that we do not own.

Instead, the new fdtest.Exists provides a helper that performs the
equivalent of fstat(2) on each OS to determine if the FD is valid,
without using os.File.

We also reuse this helper on a variety of other tests that look at open
FDs.

Fixes #49533

Change-Id: I36e2bdb15f271ab01e55c18db6564271995a15af
Reviewed-on: https://go-review.googlesource.com/c/go/+/364035
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agodebug/pe,debug/macho: add support for DWARF5 sections
Alessandro Arzilli [Mon, 15 Nov 2021 09:14:04 +0000 (10:14 +0100)]
debug/pe,debug/macho: add support for DWARF5 sections

Adds the same logic used in debug/elf to load DWARF5 sections.

Fixes #49590

Change-Id: Iee05b9927a6f521842b330eab8942ade3fc2bd86
Reviewed-on: https://go-review.googlesource.com/c/go/+/363895
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Than McIntosh <thanm@google.com>

3 years agocmd: pull in golang.org/x/mod@3a5865c
Michael Matloob [Mon, 15 Nov 2021 21:19:29 +0000 (16:19 -0500)]
cmd: pull in golang.org/x/mod@3a5865c

This change updates the cmd module's requirement on x/mod and vendors in
the changes.

This pulls in the following changes into our vendored copy of x/mod:
golang.org/cl/351319: module: accept trailing slash in MatchPrefixPattern
golang.org/cl/353749: semver: remove unused err field
golang.org/cl/355630: x/mod: update requirement on x/crypto
golang.org/cl/359412: modfile: rename directory directive to use

Changes have been made in cmd/go renaming all uses of directory to use
and fixing references to functions in x/mod/modfile to account for the
changes in the last of thse CLs.

For #45713

Change-Id: I9121d08f6e6b11838bca50e6cbd756baeeae867b
Reviewed-on: https://go-review.googlesource.com/c/go/+/364114
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agoruntime: get tracking time only when needed
Michael Pratt [Tue, 16 Nov 2021 16:46:42 +0000 (11:46 -0500)]
runtime: get tracking time only when needed

casgstatus currently calls nanotime on every casgstatus when tracking,
even though the time is only used in some cases. For goroutines making
lots of transitions that aren't covered here, this can add a small
overhead. Switch to calling nanotime only when necessary.

Change-Id: I2617869332e8289ef33dd674d786e44dea09aaba
Reviewed-on: https://go-review.googlesource.com/c/go/+/364375
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types, types2: improve error messages referencing any
Robert Findley [Mon, 15 Nov 2021 14:42:03 +0000 (09:42 -0500)]
go/types, types2: improve error messages referencing any

Because any is an a alias, it is naively formatted as interface{} in
error messages. This is a source of verbosity and potential confusion.

We can improve the situation by looking for pointer equality with the
any type. To avoid churn in the importers, do this all at once across
the compiler, go/types, and go/internal/gcimporter. CL 364194 makes the
corresponding change in x/tools/go/internal/gcimporter, allowing the
x/tools trybots to pass.

Fixes #49583

Change-Id: Ib59570937601308483f6273364cc59338f9b8b3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/363974
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agocmd/compile: prevent irgen crashing for empty local declaration stmt
Cuong Manh Le [Tue, 16 Nov 2021 14:59:15 +0000 (21:59 +0700)]
cmd/compile: prevent irgen crashing for empty local declaration stmt

Updates #47631
Fixes #49611

Change-Id: Ib4a4466038e0d4a9aa9380d7909f29f7d15c6c69
Reviewed-on: https://go-review.googlesource.com/c/go/+/364314
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agogo/types: remove asTypeParam and simplify some code
Robert Findley [Tue, 16 Nov 2021 04:39:22 +0000 (23:39 -0500)]
go/types: remove asTypeParam and simplify some code

This is a port of CL 363438 from types2 to go/types.

Change-Id: I87c76d31b398b9ce406f96b0030ee458619b3dbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/364235
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: remove structuralString in favor of inlined code
Robert Findley [Tue, 16 Nov 2021 04:29:25 +0000 (23:29 -0500)]
go/types: remove structuralString in favor of inlined code

This is a clean port of CL 363154 from types2 to go/types.

Change-Id: I26c18767041db096390e84ba9200ec69b66778d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/364234
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: slightly relax notion of structural type
Robert Findley [Tue, 16 Nov 2021 03:42:41 +0000 (22:42 -0500)]
go/types: slightly relax notion of structural type

This is a port of CL 363075 from types2 to go/types, adjusted for the
different error reporting API, and to adjust positions of error messages
in tests.

Change-Id: Ic6bfedf1152eff94bad20725b56e6ba804b2e3e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/363991
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: refer to structural rather than single underlying type in errors
Robert Findley [Tue, 16 Nov 2021 03:33:22 +0000 (22:33 -0500)]
go/types: refer to structural rather than single underlying type in errors

This is a port of CL 362997 from types2 to go/types. Some error
positions were adjusted in tests.

Change-Id: I6a932aee1a8d9bcbf4cd8c16a95bbb41b5c7e13f
Reviewed-on: https://go-review.googlesource.com/c/go/+/363990
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: move some functions into different files (cleanup)
Robert Findley [Tue, 16 Nov 2021 03:27:19 +0000 (22:27 -0500)]
go/types: move some functions into different files (cleanup)

This is a clean port of CL 362995 from types2 to go/types.

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

3 years agogo/types: rename structure to structuralType
Robert Findley [Tue, 16 Nov 2021 03:23:24 +0000 (22:23 -0500)]
go/types: rename structure to structuralType

This is a clean port of CL 362994 from types2 to go/types.

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

3 years agogo/types: use type variables consistently in Checker.conversion
Robert Findley [Tue, 16 Nov 2021 03:22:26 +0000 (22:22 -0500)]
go/types: use type variables consistently in Checker.conversion

This is a clean port of CL 362895 from types2 to go/types.

Change-Id: Icd0631127c51aec80ce9450df2be71bf4b96b2df
Reviewed-on: https://go-review.googlesource.com/c/go/+/363987
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agoall: update vendored golang.org/x/tools
Robert Findley [Tue, 16 Nov 2021 02:12:33 +0000 (21:12 -0500)]
all: update vendored golang.org/x/tools

Update the vendored x/tools to pick up the fix for #49597, using the
following commands:

  go get -d golang.org/x/tools@4adea5033c5c6f39a900d4b963c4b496448b1655
  go mod tidy
  go mod vendor

Fixes #49597

Change-Id: Ib1bc43aacbdc707b605194012134f048a336e176
Reviewed-on: https://go-review.googlesource.com/c/go/+/363986
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/go: don't try to print build info of non-Go binaries
Alberto Donizetti [Wed, 27 Oct 2021 15:37:09 +0000 (17:37 +0200)]
cmd/go: don't try to print build info of non-Go binaries

On a non-nil err, buildinfo.ReadFile will always return a nil
*Buildinfo. In scanFile, we need to return early if that happens.

Fixes #49181

Change-Id: I354348d206ab084804937c6f922eadb61435e7b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/359154
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/compile/internal/types2: re-use type hashing logic in Context.typeHash
Robert Griesemer [Mon, 15 Nov 2021 23:28:12 +0000 (15:28 -0800)]
cmd/compile/internal/types2: re-use type hashing logic in Context.typeHash

This CL is clean port of CL 362800 from go/types to types2.

Change-Id: I66443b5a82b3a9c2f608a0fe012fbb099db996f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/364155
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: refactor the Context type map to accept arbitrary types
Robert Griesemer [Mon, 15 Nov 2021 23:21:42 +0000 (15:21 -0800)]
cmd/compile/internal/types2: refactor the Context type map to accept arbitrary types

This CL is a clean port of CL 362799 from go/types to types2.

Change-Id: Id670aa4b1ca0b568a79bb6e4855747807dcf00f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/364154
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: use Identical to verify type identity in the Context map
Robert Griesemer [Mon, 15 Nov 2021 22:56:33 +0000 (14:56 -0800)]
cmd/compile/internal/types2: use Identical to verify type identity in the Context map

This is a clean port of CL 362798 from go/types to types2,
with an additional comment adjustment in types2 and go/types.

Change-Id: Ifa3d11f512f794f8ae2b6aca50b625a4a44672de
Reviewed-on: https://go-review.googlesource.com/c/go/+/364135
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agodoc: mention generics in release notes
Keith Randall [Mon, 15 Nov 2021 22:42:42 +0000 (14:42 -0800)]
doc: mention generics in release notes

Also mention local types restriction.

We probably want to say more at some point, this is just a
placeholder to start.

Update #47631

Change-Id: I828e451e1e8504d21cb55c7132e9cb330b160a54
Reviewed-on: https://go-review.googlesource.com/c/go/+/364134
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agosync: in TryLock try to acquire mutex even if state is not 0
Ian Lance Taylor [Sat, 13 Nov 2021 22:36:35 +0000 (14:36 -0800)]
sync: in TryLock try to acquire mutex even if state is not 0

For #45435

Change-Id: I728accd9a53c1826243f52aa04dc2a0a1dfdaadf
Reviewed-on: https://go-review.googlesource.com/c/go/+/363672
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
3 years agodoc/go1.18: add AppendRune doc
jiahua wang [Fri, 12 Nov 2021 02:15:21 +0000 (10:15 +0800)]
doc/go1.18: add AppendRune doc

For #47694

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

3 years agodebug/dwarf: better error message when reading absent debug_line_str
Alessandro Arzilli [Mon, 15 Nov 2021 08:42:28 +0000 (09:42 +0100)]
debug/dwarf: better error message when reading absent debug_line_str

When a DW_FORM_line_strp is used without a debug_line_str section a
good error message (about the missing section) is generated but
immediately overwritten by the underflow error generated by trying to
read the non-existent section.

Updates #49590

Change-Id: I1c431392123a86c78c95ef1f185ebd6f17f2476a
Reviewed-on: https://go-review.googlesource.com/c/go/+/363894
Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Trust: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/compile/internal/types2: add test for imported constraints pre-1.18
Robert Griesemer [Sun, 14 Nov 2021 00:16:53 +0000 (16:16 -0800)]
cmd/compile/internal/types2: add test for imported constraints pre-1.18

But exclude the test when running unified build for now
(the unified builder's importers are not yet updated to
handle extended interfaces).
Also, fix respective error position.

Fixes #47967.

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

3 years agocmd/compile/internal/types2: use "implements" rather than "satisfies" in error messages
Robert Griesemer [Mon, 15 Nov 2021 05:13:27 +0000 (21:13 -0800)]
cmd/compile/internal/types2: use "implements" rather than "satisfies" in error messages

Type constraint satisfaction is interface implementation.

Adjusted a few error messages.

Change-Id: I4266af78e83131a76b1e3e44c847a21de760ac6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/363839
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: remove unneccesary tests in implements and lookup
Robert Griesemer [Mon, 15 Nov 2021 04:45:40 +0000 (20:45 -0800)]
cmd/compile/internal/types2: remove unneccesary tests in implements and lookup

Because the underlying type of a type parameter is an interface,
the questions whether *P for a type parameter P has methods or
not is settled: P is also an interface pointers to interfaces
don't have methods.

This allows us to eliminate the now unneccesary test in "implements"
and also allows us to remove a special case for type parameters in
"lookupFieldOrMethod".

Change-Id: I8b218f81584a8e42e75884089a44293365b700df
Reviewed-on: https://go-review.googlesource.com/c/go/+/363838
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: implement Checker.implements
Robert Griesemer [Sun, 14 Nov 2021 19:29:45 +0000 (11:29 -0800)]
cmd/compile/internal/types2: implement Checker.implements

Checker.implements implements the complete interface
"implements" predicate. Use it instead of Checker.satisfies.
This is mostly a refactoring of the code but the constraint
types have already been instatiated with the respective type
arguments as needed before calling "implements".
Future CLs will address the various TODOs.

Change-Id: If530cca36643a561282361348f1526157a7182de
Reviewed-on: https://go-review.googlesource.com/c/go/+/363837
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: better position for invalid slice indices error
Robert Griesemer [Sat, 13 Nov 2021 21:57:48 +0000 (13:57 -0800)]
cmd/compile/internal/types2: better position for invalid slice indices error

Report the error at the first place (which is to say, latest index)
causing the error.

Change-Id: I31cf0a4d243fc66cfab84b7fec98055f4eb60ddf
Reviewed-on: https://go-review.googlesource.com/c/go/+/363671
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: better position for "3-index slice of string" error
Robert Griesemer [Sat, 13 Nov 2021 21:37:15 +0000 (13:37 -0800)]
cmd/compile/internal/types2: better position for "3-index slice of string" error

As a result, slightly narrow position tolerance for tests.

Change-Id: I543dc2b7b9a7940b0684067d1961165b2b4812bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/363670
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: move match function to end of file (cleanup)
Robert Griesemer [Sat, 13 Nov 2021 20:04:01 +0000 (12:04 -0800)]
cmd/compile/internal/types2: move match function to end of file (cleanup)

Change-Id: Ia09f7b1af0e84858fb73ab7e2592c5c3e983dc0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/363669
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: allow slicing for operands with []byte|string type sets
Robert Griesemer [Fri, 12 Nov 2021 23:08:00 +0000 (15:08 -0800)]
cmd/compile/internal/types2: allow slicing for operands with []byte|string type sets

Fixes #49566.

Change-Id: I80ff4ca661f82b0981d51e0997d5988a9b82f508
Reviewed-on: https://go-review.googlesource.com/c/go/+/363662
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: optimize common case in structuralType
Robert Griesemer [Sat, 13 Nov 2021 19:02:51 +0000 (11:02 -0800)]
cmd/compile/internal/types2: optimize common case in structuralType

Most of the time we don't have a type parameter. Avoid using a
closure in that case.

While at it, rename argument from typ to t (to match style in
that file), and clarify the doc string.

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