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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Robert Griesemer [Sun, 14 Nov 2021 19:31:47 +0000 (11:31 -0800)]
go/types, types2: copy implicit bit in interface substitution
Change-Id: Idb02449ef1b06d5f47eeb4a4413e56e2cd5d0d96
Reviewed-on: https://go-review.googlesource.com/c/go/+/363836
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>
Keith Randall [Mon, 15 Nov 2021 18:01:43 +0000 (10:01 -0800)]
cmd/compile: error when using internal type declarations in generic functions
We hope to support this feature one day, but it doesn't work currently.
Issue a nice error message instead of having the compiler crash.
Update #47631
Change-Id: I0359411410acbaf9a5b9dbb988cd933de1bb8438
Reviewed-on: https://go-review.googlesource.com/c/go/+/364054
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
Robert Findley [Mon, 15 Nov 2021 16:47:55 +0000 (11:47 -0500)]
cmd/compile/internal/types2: add a check for nil reason in assignableTo
A recent change to error message formatting was missing a nil check.
Fixes #49592
Change-Id: Ic1843e0277ba75eec0e8e41fe34b59c323d7ea31
Reviewed-on: https://go-review.googlesource.com/c/go/+/364034
Trust: Robert Findley <rfindley@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: Daniel Martà <mvdan@mvdan.cc>
Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Robert Findley [Mon, 15 Nov 2021 15:49:54 +0000 (10:49 -0500)]
go/types: return an error message from Checker.genericType
The bare error message "%s is not a generic type" is probably never
sufficient, so change the signature of genericType to instead return an
message that may be formatted as additional context in errors.
Along the way, refactor instantiatedType to have access to the entire
index expression.
Fixes #48827
Change-Id: I0c455c1ce46ac3f1ef2990c997da19e5fc6c4eae
Reviewed-on: https://go-review.googlesource.com/c/go/+/363994
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>
Robert Findley [Mon, 15 Nov 2021 01:34:58 +0000 (20:34 -0500)]
go/types: assign error codes to new errors for Go 1.18
During development, we used placeholder _Todo error codes for new
errors related to generics. Add real error codes in these places.
As a result, 9 new error codes are added for ~50 call sites.
Change-Id: Ib57b4cd9f0a2e160971a3aeea18f9fe26fc0f835
Reviewed-on: https://go-review.googlesource.com/c/go/+/363874
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>
Dan Scales [Sun, 14 Nov 2021 00:17:52 +0000 (16:17 -0800)]
cmd/compile: fix position info for implicit nodes due to generics
The main fix is that we should call ir.SetPos() at the beginning of
(*subster).node.edit function, since that is analogous to the
ir.SetPos() at the beginning of typecheck.typecheck(). It ensures that
transform functions can use base.Pos() with appropriate results, just
like their corresponding tc*() functions do.
A small fix is to make sure that the new nodes creates for dictionary
references have the correct position based on the location of the
function call.
Another small fix is to the use of base.Pos when creating a new selector
expression (including implicit XDOTs) for a method expression in
buildClosure().
Also, I converted the final use of base.Pos in stencil.go to src.NoXPos,
since the nodes created by AddImplicitDots will be checked for their
type, but won't actually be used.
I also needed to add an ir.SetPos() at the beginning of transformCall(),
since transformCall() is called in the modify and dict passes, when we
base.Pos is not being set for each node.
This change fixes all the line numbering problems printed out from
Alessandro's program, except for auto-generated functions (which I think
are fine).
Fixes #49523
Change-Id: I9836a497b7beba25ecafdde653a6c2036a3020d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/363835
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>
Michael Anthony Knyszek [Thu, 11 Nov 2021 18:12:20 +0000 (18:12 +0000)]
runtime: fix released bytes accumulation in bg scavenger
Currently "released" is not accumulated bytes released. If the last
attempt to scavenge ends up as 0, then the scavenger will go to sleep
too soon. This is an artifact from the old code where scavenge would
only be called into once.
Change-Id: I85aa2261f1504a6fb5bf086daa029eecb0e09cf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/363416
Trust: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Cherry Mui [Sat, 13 Nov 2021 00:53:28 +0000 (19:53 -0500)]
cmd/compile, runtime: mark R1 as clobbered for write barrier call
If the call to gcWriteBarrier is via PLT, the PLT stub will
clobber R1. Mark R1 clobbered.
For #49386.
Change-Id: I72df5bb3b8d10381fec5c567b15749aaf7d2ad70
Reviewed-on: https://go-review.googlesource.com/c/go/+/363698
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Keith Randall [Fri, 12 Nov 2021 20:38:29 +0000 (12:38 -0800)]
cmd/compile: ensure we replace package placeholder in type names
We want package names exposed by reflect to be things like
main.F[main.foo], not main.F["".foo].
Fixes #49547
Change-Id: I182411a75d56ce1f64fde847e5b9ee74ce44e00b
Reviewed-on: https://go-review.googlesource.com/c/go/+/363656
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
Keith Randall [Fri, 12 Nov 2021 23:48:01 +0000 (15:48 -0800)]
doc: document GOAMD64 environment variable
Update #47694
Change-Id: I9c90bd251616cd4d10434bd3b6e6c30c5c819e24
Reviewed-on: https://go-review.googlesource.com/c/go/+/363661
Trust: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Robert Griesemer [Sat, 13 Nov 2021 02:24:54 +0000 (18:24 -0800)]
cmd/compile/internal/types2: simplify under() and fix a crash
The simplified version of under exposed a bug (by crashing):
When a pointer base is used before the pointer is fully set
up, the base is nil. Set the pointer base to Typ[Invalid]
when creating the pointer, and add an extra safety check
into deref. Reviewed all code that creates pointers.
The same error cannot happen with other types because
accessing parts of another type results in an expression
that is not a type, and thus these kids of cycles cannot
happen.
Change-Id: I8332a281a534c094cfbb3623a636960865813ff6
Reviewed-on: https://go-review.googlesource.com/c/go/+/363665
Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Robert Findley [Fri, 12 Nov 2021 16:46:23 +0000 (11:46 -0500)]
go/types: return an error from Instantiate on incorrect len(targs)
Instantiate already returns an error when validation fails. Panicking on
an incorrect number of type arguments means that callers must both
pre-validate the number of type arguments and handle resulting errors.
Returning an error rather than panicking allows eliminating
pre-validation at the call-site.
Also update the Instantiate docstring to correct some stale/inaccurate
information, and to clarify its behavior more precisely.
Updates #47916
Change-Id: I997ef30b3486760a90b0db4c3ea7111280d74a81
Reviewed-on: https://go-review.googlesource.com/c/go/+/363635
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>
Robert Findley [Fri, 12 Nov 2021 01:15:02 +0000 (20:15 -0500)]
go/types: add a test for Context deduplication of hash collisions
Add a test that exercises the fall-back logic in Context to handle hash
collisions by de-duplicating using Identical.
This has to be a somewhat invasive test because we don't know any actual
cases of hash collisions.
Change-Id: Idf00f7a6ab8c7517ed0f91fdc42d54f5e736b1b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/363517
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>
Robert Findley [Sat, 13 Nov 2021 01:15:49 +0000 (20:15 -0500)]
test: fix longtest failures on fixedbugs/issue48471.go
This test is failing with -G=0, so specify -G=3.
Change-Id: I4c74707d0a43f8191cb0b156204604458ba85136
Reviewed-on: https://go-review.googlesource.com/c/go/+/363699
Trust: Robert Findley <rfindley@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
Robert Findley [Wed, 10 Nov 2021 21:58:45 +0000 (16:58 -0500)]
go/types: rename types.context to types.environment
Now that we have a Context type the context (unexported) type is
particularly confusing. Rename it to environment.
Change-Id: I7d280439b8263d9ebfd561fc4d59c6d43c8d3e3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/363176
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>
Robert Findley [Wed, 10 Nov 2021 21:52:17 +0000 (16:52 -0500)]
go/types: don't set a Config.Context if none is provided
Users can re-use a type checking context by passing it via types.Config.
There is no need for us to expose the internal type checking context
when the config context is unset, and in fact doing so could lead to a
memory leak for users that re-use types.Config, expecting it to be small
and immutable.
Keep track of the Context on Checker instead, and zero it out at the end
of type checking.
Change-Id: Iff5b328a09cd0af76fcd4869f5f15352131b5986
Reviewed-on: https://go-review.googlesource.com/c/go/+/363175
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>
Robert Findley [Wed, 10 Nov 2021 20:54:00 +0000 (15:54 -0500)]
go/types: when type hashing, canonicalize interfaces
The interface type string preserves certain non-semantic attributes of
the type, such as embedded interfaces. We want the hash to represent the
interface identity, so hash the type set representation of the interface
instead.
Change-Id: I14081ac20b738c5fe11785e0846a9b4358594768
Reviewed-on: https://go-review.googlesource.com/c/go/+/363115
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>
Robert Findley [Wed, 10 Nov 2021 20:53:16 +0000 (15:53 -0500)]
go/types: when type hashing, use placeholders for type parameters
Type parameter names don't matter for the purposes of generic type
identity, so mask them with numeric placeholders when hashing.
Change-Id: Iacb4c23abecdd733fc292ae13ecac6baa2c5524c
Reviewed-on: https://go-review.googlesource.com/c/go/+/363114
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>
Robert Findley [Wed, 10 Nov 2021 03:31:59 +0000 (22:31 -0500)]
go/types: deduplicate signatures with the context
Extend the type checking context to allow de-duplicating *Signature
instances, in addition to *Named instances.
Naively we would deduplicate instances of different-but-identical origin
*Signature types. That may be OK, but it seems a bit strange to get the
same signature when instantiating two different functions. For now,
differentiate *Signature types by prepending a unique identifier for the
origin pointer, thus guaranteeing that instances de-duplicated if they
come from the exact same (pointer identical) origin type.
Updates #47103
Change-Id: I93cc3cacad195267fe0a5801f9c5a3b1e61eb907
Reviewed-on: https://go-review.googlesource.com/c/go/+/362801
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>
Robert Griesemer [Fri, 12 Nov 2021 16:59:49 +0000 (08:59 -0800)]
cmd/compile/internal/types2: remove tparamIsIface flag and corresponding dead code
Added/clarified some comments.
Change-Id: Ib08d3343ff08c23cc8880a27a0148d1ff077a80f
Reviewed-on: https://go-review.googlesource.com/c/go/+/363654
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>
Robert Griesemer [Fri, 12 Nov 2021 06:21:48 +0000 (22:21 -0800)]
cmd/compile/internal/types2: remove asNamed
In the few remaining places where we use asNamed, if the argument
is indeed a *Named, we either don't need to look "inside" it, or
we call under() (which calls Named.underlying() which does resolve);
so there's no need for an implicit resolution (which was done by
asNamed). The only place where we do need to resolve is in lookup,
so added the explicit resolve call in that case.
Change-Id: Iff0a19fde7581e94149e89b9e48157c1981db105
Reviewed-on: https://go-review.googlesource.com/c/go/+/363441
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>
Robert Griesemer [Wed, 10 Nov 2021 23:50:35 +0000 (15:50 -0800)]
cmd/compile/internal/types2: set tparamsIsIface to true
This CL enables the mode in which the underlying type of
type parameters is the underlying type of their constraints.
Change-Id: Id3471578dab098695dbd1e0429356ebcc9c5e224
Reviewed-on: https://go-review.googlesource.com/c/go/+/363155
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>
Robert Griesemer [Tue, 26 Oct 2021 17:06:55 +0000 (10:06 -0700)]
cmd/compile/internal/types2: underlying type of a type parameter is its constraint interface
Until now, the type checker operated with the definition that the
underlying type of a type parameter is itself. This leads to some
inconcistencies and caused us to disallow type declarations where
the RHS is a stand-alone type parameter.
This change implements an alernative definition: the underlying
type of a type parameter is the underlying type of its constraint;
i.e., the underlying type of a type parameter is always an interface
(because constraints must be interfaces). This matches the theory
closely and also resolves some inconsistencies. For example, we
don't need to prohibit stand-alone type parameters on the RHS of
a type declaration (though, for the sake of keeping the tests the
same, we still do in this CL). We also get a clear understanding of
what it would mean to use a type assertion or type switch on a type
parameter (still disabled with this CL). Finally, the declaration
of a type parameter now very closely matches the definition of an
ordinary type.
The main consequence is that the rules for assignment need to be
slightly modified: even though a type parameter is an interface,
we cannot simply assign to it per the rules for interfaces: the
type parameter's type is fixed for the instantiation and we need
to reflect that accordingly when checking for assignability.
This CL does not enable the new mode, it implements it in parallel
to the existing mode; the internal flag tparamIsIface is used to
switch between the modes.
The changes to the code are numerous, but straight-forward: when-
ever we deal with an underlying type that might be a type parameter
(or newly, an interface), we need to act slightly differently. For
the time being this leads to some code duplication because the code
supports both modes.
While some of the code for the new mode seems more complicated
(e.g., when we have an interface, the code checks that it is not
the underlying type of a type parameter), in reality many of the
extra checks are redundant and only present because of an abundance
of caution: interfaces with specific type sets are not permitted as
types for ordinary variables, and so even if we were to hit those
cases w/o excluding type parameters the behavior would be the same.
Runs all tests with tparamIsIface enabled and disabled.
Current setting: disabled.
Change-Id: I7bb6453f4fe2569d92face222058fb4e17b12f25
Reviewed-on: https://go-review.googlesource.com/c/go/+/359016
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>
Robert Griesemer [Fri, 12 Nov 2021 21:23:45 +0000 (13:23 -0800)]
cmd/compile/internal/types2: make sure we are safe for nil in underIs
Reviewed all uses of underIs (global function and method) and made
sure we are ok with a nil incoming argument (indicating a type set
with no specific types).
Added a couple of checks where we didn't have them (and somehow
didn't run into a problem yet).
Change-Id: Ifde45a3a80ddf2b1a19c83f79258ad8207dfb09f
Reviewed-on: https://go-review.googlesource.com/c/go/+/363658
Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Dan Scales [Thu, 11 Nov 2021 18:28:17 +0000 (10:28 -0800)]
cmd/compile: add missing method info for method with correct name except for case
When being used by the compiler, augment the types2 missing method
message with extra info, if a method is missing, but a method with the
correct name except for case (i.e. equal via string.EqualFold()) is
present. In that case, print out the wanted method and the method that
is present (that has the wrong case).
In the 1.17 compiler, we don't do this case-folding check when assigning
an interface to an interface, so I didn't add that check, but we could
add that.
Fixes #48471
Change-Id: Ic54549c1f66297c9221d979d49c1daa719aa66cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/363437
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Dan Scales [Wed, 10 Nov 2021 16:41:21 +0000 (08:41 -0800)]
cmd/compile: match Go 1.17 compiler error messages more closely
When being used by the compiler, fix up types2 error messages to be more
like Go 1.17 compiler errors. In particular:
- add information about which method is missing when a type is not
assignable/convertible/etc. to an interface.
- add information about any existing method which has the same name,
but wrong type.
- add extra hint in the case that the source or destination type is a
pointer to an interface, rather than an interface.
- add extra hint "need type assertion" in the case that the source is
an interface that is implemented by the destination.
- the following change in the CL stack also adds information about any
existing method with a different name that only differs in case.
Include much of the new logic in a new common function
(*Checker).missingMethodReason().
types2 still adds a little more information in some cases then the Go
1.17 compiler. For example, it typically says "(value of type T)",
rather than "(type T)", where "value" could also be "constant",
"variable", etc.
I kept the types2 error messages almost all the same when types2 is not
used by the compiler. The only change (to reduce amount of compatibility
code) was to change "M method" phrasing in one case to "method M"
phrasing in one error message (which is the phrasing it uses in all
other cases). That is the reason that there are a few small changes in
types2/testdata/check/*.src.
Added new test test/fixedbugs/issue48471.go to test that the added
information is appearing correctly.
Also adjusted the pattern matching in a bunch of other
test/fixedbugs/*.go, now that types2 is producing error messages closer
to Go 1.17. Was able to remove a couple test files from the types2
exception list in run.go.
Updated #48471
Change-Id: I8af1eae6eb8a5541d8ea20b66f494e2e795e1956
Reviewed-on: https://go-review.googlesource.com/c/go/+/363436
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Robert Griesemer [Fri, 12 Nov 2021 00:02:35 +0000 (16:02 -0800)]
cmd/compile/internal/types2: remove asTypeParam and simplify some code
Because we do not permit a stand-alone type parameter on the RHS of
a type declaration, the underlying type of a (Named) type cannot be
a type parameter. This allows us to simplify some code.
Specifically, when parsing union elements, we don't need to delay
a check for later, which allows further simplifications when computing
type sets.
Change-Id: I4047c609f87ebb194ea8c1bad630a70d255b20cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/363438
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>
Michael Pratt [Wed, 10 Nov 2021 17:56:40 +0000 (12:56 -0500)]
runtime: start ARM atomic kernel helper traceback in caller
Like the VDSO, we cannot directly traceback from the Linux kernel ARM
atomic/barrier helpers. However, unlike the VDSO, this functions are
extremely simple. Neither of the functions we use, kuser_cmpxchg and
kuser_memory_barrier, touch SP or LR.
We can use this to our advantage to read LR and simply start tracebacks
in the caller.
Fixes #49182
Change-Id: I890edbeb7c128938000fe7baf6f913c02a956edd
Reviewed-on: https://go-review.googlesource.com/c/go/+/362977
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
Damien Neil [Mon, 8 Nov 2021 19:23:27 +0000 (11:23 -0800)]
net/http: do not cancel request context on response body read
When sending a Request with a non-context deadline, we create a
context with a timeout. This context is canceled when closing the
response body, and also if a read from the response body returns
an error (including io.EOF).
Cancelling the context in Response.Body.Read interferes with the
HTTP/2 client cleaning up after a request is completed, and is
unnecessary: The user should always close the body, the impact
from not canceling the context is minor (the context timer leaks
until it fires).
Fixes #49366.
Change-Id: Ieaed866116916261d9079f71d8fea7a7b303b8fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/361919
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Michael Pratt [Wed, 10 Nov 2021 22:35:13 +0000 (17:35 -0500)]
runtime/pprof: mark TestCPUProfileMultithreadMagnitude as flaky
The Linux kernel starting in 5.9 and fixed in 5.16 has a bug that can
break CPU timer signal delivery on new new threads if the timer
interrupt fires during handling of the clone system call.
Broken CPU timer signal deliver will skew CPU profile results and cause
this test to fail.
There is currently no known workaround, so mark the test as flaky on
builders with known broken kernels.
For #49065
Change-Id: I37ceb9ea244869b0aab5cd9a36b27ca2f7e5d315
Reviewed-on: https://go-review.googlesource.com/c/go/+/363214
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
Michael Pratt [Fri, 12 Nov 2021 16:16:43 +0000 (11:16 -0500)]
runtime: drop cgoTraceback call assumptions from CgoPprof tests
the CgoPprof tests currently assume that calls to their cgoTraceback
functions are primarily for generating pprof samples and exit early
after receiving two calls.
This is a fragile assumption, as cgoTraceback will be called for _any_
signal received, hence why the test already looks for 2 calls instead of
1.
Still, this has caused flaky failures in two cases:
* #37201, where async preemption signals add additional probability of
receiving non-profiling signals. This was resolved by disabling async
preemption.
* #49401, where some ITIMER_PROF SIGPROF signals are ignored in favor of
per-thread SIGPROF signals.
Rather than attempting to keep plugging holes, this CL drops the fragile
assumption from these tests. Now they simply unconditionally run for the
full 1s before exiting.
Fixes #49401
Change-Id: I16dc9d2f16c2fb511e9db93dd096a402121f86ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/363634
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Rhys Hiltner <rhys@justin.tv>