Commit graph

48982 commits

Author SHA1 Message Date
Rob Findley 22a38ba5ca [dev.typeparams] go/types: remove unnecessary guard from NewInterfaceType
This is a partial port of CL 322609, containing only changes to
go/types. Importer changes will be made in a separate CL.

Change-Id: I50af3c1ed5e949bb28a3462d717c0eb29a5f31ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/335144
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-19 15:50:21 +00:00
Rob Findley b96f1b9419 [dev.typeparams] go/types: add some missing APIs for the importer
This is a partial port of CL 319930, containing only changes to
go/types. Importer changes will be made in a separate CL.

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

Change-Id: I74bd246d4c174cb38f8360d921c733fa03900eab
Reviewed-on: https://go-review.googlesource.com/c/go/+/335143
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-19 15:50:07 +00:00
Rob Findley 43ad1ffa99 [dev.typeparams] go/types: recursive substitution must terminate (bug fix)
This is a port of CL 333383 to go/types.

Change-Id: I7ff68116cbe63337dbcc834c473a2a5588274e36
Reviewed-on: https://go-review.googlesource.com/c/go/+/335115
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-19 15:49:58 +00:00
Rob Findley c7c13ae432 [dev.typeparams] go/types: use scope numbers to identify local types
This is a port of CL 333192 to go/types.

Change-Id: I12fd6b682d40c4d30b9ac0e87c463843cf5030d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/335114
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-19 15:49:47 +00:00
Rob Findley ccf95f17dd [dev.typeparams] go/types: support local defined types
This is a port of CL 327170 to go/types. Tests were not ported; they can
be added later.

Change-Id: Ic9fd681ac06dd187c1715efaf882b11353bc395a
Reviewed-on: https://go-review.googlesource.com/c/go/+/335113
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-19 15:49:09 +00:00
Rob Findley 76b39959f4 [dev.typeparams] go/types: don't permit method calls on ptr to type parameter receivers
This is a port of CL 332609 to go/types.

Change-Id: I3482ea1b97bc7101b987ef312cd6cade80a5843f
Reviewed-on: https://go-review.googlesource.com/c/go/+/335112
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-19 15:48:55 +00:00
Than McIntosh 49402bee36 cmd/{compile,link}: fix bug in map.zero handling
In CL 326211 a change was made to switch "go.map.zero" symbols from
non-pkg DUPOK symbols to hashed symbols. The intent of this change was
ensure that in cases where there are multiple competing go.map.zero
symbols feeding into a link, the largest map.zero symbol is selected.
The change was buggy, however, and resulted in duplicate symbols in
the final binary (see bug cited below for details). This duplication
was relatively benign for linux/ELF, but causes duplicate definition
errors on Windows.

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

Fixes #47185.

Change-Id: I8aeb910c65827f5380144d07646006ba553c9251
Reviewed-on: https://go-review.googlesource.com/c/go/+/334930
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-07-19 13:27:46 +00:00
Dan Scales 9b85985d36 [dev.typeparams] Separate out gcshape types that are instantiated types
Distinguish the gcshape of all top-level instantiated type from normal
concrete types, even if they have the exact same underlying "shape",
because in a function instantiation, any method call on this type arg
will be a generic method call (requiring a dictionary), rather than a
direct method call on the underlying type (no dictionary).

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

Change-Id: I33056269d24f3451a2632a5ce6a481108f533c9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/335169
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-07-19 05:02:24 +00:00
nimelehin a66190ecee test/bench/go1: fix size for RegexpMatchMedium_32
Change-Id: Idc67abb95248bc010820a89dd6096a2da334e723
GitHub-Last-Rev: ae9014b011
GitHub-Pull-Request: golang/go#47254
Reviewed-on: https://go-review.googlesource.com/c/go/+/335189
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
2021-07-18 21:03:43 +00:00
mehradsadeghi 650fc2117a text/scanner: use Go convention in Position doc comment
Change-Id: Ib872f139af7bfb0a75cc21dace5358fe8fcf2cf0
GitHub-Last-Rev: 8fd5ab01fa
GitHub-Pull-Request: golang/go#47250
Reviewed-on: https://go-review.googlesource.com/c/go/+/335149
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Robert Griesemer <gri@golang.org>
2021-07-18 21:00:03 +00:00
Rob Findley df778e6fd9 [dev.typeparams] go/types: replace optype() with under() in various cases (cleanup)
This is a port of CL 332555 to go/types.

Change-Id: I9b26bba8b605f5bbbd8f0f81fd6651a4a3ff4b57
Reviewed-on: https://go-review.googlesource.com/c/go/+/335111
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-07-17 01:52:18 +00:00
Rob Findley e9836fe318 [dev.typeparams] go/types: clean up index expr implementation for type parameters
This is a port of CL 332553 to go/types. The "expr" variable is renamed to
"e" in Checker.indexExpr to be consistent with types2.

Change-Id: I7905bebf2e8dab47256361362b16becf7596cf95
Reviewed-on: https://go-review.googlesource.com/c/go/+/335110
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
2021-07-17 01:38:18 +00:00
Rob Findley c4cd76fbbb [dev.typeparams] go/types: disallow "free" type parameter as RHS of a type declaration
This is a port of CL 332411 to go/types. methodset_test.go is similarly
updated.

Change-Id: I332b1837a954acc9d3b7e0e2ad2bec3425f088f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/335109
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Robert Findley <rfindley@google.com>
2021-07-17 01:35:49 +00:00
Rob Findley 521828091c [dev.typeparams] go/types: move (remaining) type decls into their own files (cleanup)
This is a port of CL 332093 to go/types. A missing comment is added to
named.go, and some TODOs were added to converge on the TypeParam API.

Change-Id: I781a1d0d3fc6c11bb323123e954c106094d998ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/335040
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:35:10 +00:00
Rob Findley 624d152db7 [dev.typeparams] go/types: move Interface type decl into interface.go (cleanup)
This is a port of CL 332092 to go/types.

Change-Id: I9971c49570424368575108832eac0cd978eb3fe6
Reviewed-on: https://go-review.googlesource.com/c/go/+/335039
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:34:53 +00:00
Rob Findley e12d43866d [dev.typeparams] go/types: move Signature type decl into signature.go (cleanup)
This is a port of CL 332091 to go/types. Notably types.Signature is
missing APIs for RParams. This is left for a later CL, when the API is
finalized.

Change-Id: I70b664d656e8c1e32958a75e1d13eab5f3281bf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/335038
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:34:44 +00:00
Rob Findley b3e7f23a48 [dev.typeparams] go/types: move Struct type decl into struct.go (cleanup)
This is a port of CL 332090 to go/types.

Change-Id: Idc480374f5efe0e7f34f76f37ffd02a3aef59c67
Reviewed-on: https://go-review.googlesource.com/c/go/+/335037
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:34:35 +00:00
Rob Findley 7c35f5c2fc [dev.typeparams] go/types: rename newTypeSet -> computeTypeSet
This is a port of CL 332089 to go/types.

Change-Id: I39321eaee184c8204bd255b7770a0770ecb25fda
Reviewed-on: https://go-review.googlesource.com/c/go/+/335036
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:34:25 +00:00
Rob Findley de209e693a [dev.typeparams] go/types: make Interface.obj a *TypeName
This is a straightforward port of CL 332011 to go/types.

Change-Id: I682791886c8496c52094f3688e36934afbd7a241
Reviewed-on: https://go-review.googlesource.com/c/go/+/335035
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:34:15 +00:00
Rob Findley 0f4198b5e2 [dev.typeparams] go/types: delay interface check for type bounds
This is a port of CL 331690 to go/types. It diverges from that CL due to
the different representation of Fields in the AST.

Change-Id: I3ae9ac3a0172dc58ac748f28772d87b00db0732a
Reviewed-on: https://go-review.googlesource.com/c/go/+/335034
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:34:00 +00:00
Rob Findley 5f50a6442e [dev.typeparams] go/internal/typeparams: remove the Enabled guard
Type parameters are now always enabled. Users should guard against type
checking generic code by using the types.Config.GoVersion field.

This cleans up some differences with types2.

Change-Id: Ie3e35a549e456a90a10d6a7e158ff58653cc1394
Reviewed-on: https://go-review.googlesource.com/c/go/+/335033
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:08:28 +00:00
Rob Findley 726ffce659 [dev.typeparams] go/types: "comparable" must not be visible before Go 1.18
This is a straightforward port of CL 331517 to go/types.

Change-Id: Id00761fd5dffb4d09e19f086d18ddc20f11528d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/335032
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:07:17 +00:00
Rob Findley 79955155e9 [dev.typeparams] go/types: move newTypeSet function into typeset.go
This is a straightforward port of CL 331515 to go/types.

Change-Id: I05c687e7dd7a64a8a7815c4483ff7fbb06b37627
Reviewed-on: https://go-review.googlesource.com/c/go/+/335031
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:07:10 +00:00
Rob Findley fe4f13404d [dev.typeparams] go/types: move embedding positions from Checker to Interface
This is a straightforward port of CL 331514 to go/types, with minor
adjustments for the different position API.

Change-Id: I714b3f1cd5a0e8d249912bb589d456885a87e167
Reviewed-on: https://go-review.googlesource.com/c/go/+/335030
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:05:06 +00:00
Rob Findley b98b8b9b5b [dev.typeparams] go/types: remove unused *Checker arguments (cleanup)
This is a straightforward port of CL 331512 to go/types. API usage in
methodset.go was also updated.

Change-Id: I6701265c9d2ae40eb9aa0ea5f00c98ce3516edab
Reviewed-on: https://go-review.googlesource.com/c/go/+/335009
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:04:55 +00:00
Rob Findley fce6290e0a [dev.typeparams] go/types: remove typeparams wrappers and aliases
These wrappers and aliases were necessary when we had different versions
of the API depending on the typeparams build constraint, but now they're
just boilerplate. Remove them.

Notably the documentation for types.Info is restored.

Change-Id: I5363d1d5df47649c2641c03328dfba45b1456278
Reviewed-on: https://go-review.googlesource.com/c/go/+/334895
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:04:45 +00:00
Rob Findley 24f9eb2de3 [dev.typeparams] go/types: introduce type set abstraction for interfaces
This is a port of CL 329309 to go/types, with minor updates for API
differences and to handle methodset.go, which doesn't exist in types2.

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

Change-Id: I3fd556e1326013a694ff5edb8518ca24c27bd10b
Reviewed-on: https://go-review.googlesource.com/c/go/+/334894
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:04:35 +00:00
Rob Findley b296e54618 [dev.typeparams] go/types: port lazy import resolution from types2
This is a straightforward port of CL 323569 to go/types. It is
line-for-line identical, except where names are unexported to preserve
the current go/types API.

Change-Id: I4c78211bff90f982ca2e90ed224946716118ee31
Reviewed-on: https://go-review.googlesource.com/c/go/+/334893
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-16 23:04:27 +00:00
Keith Randall 10c8b7c1d7 [dev.typeparams] cmd/compile: use dictionary to convert arguments of ==, != to interfaces
When comparing a value whose type is a type parameter to an interface,
we need to convert that type parameter to an interface using the dictionary
entries.

Change-Id: I409c9e36e376fe4ef8163407d0fd4e84496d5b65
Reviewed-on: https://go-review.googlesource.com/c/go/+/334150
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-07-16 18:31:15 +00:00
Dan Scales ed9e109dc9 [dev.typeparams] cmd/compile: fix small -G=3 issues for tests disabled in run.go
- set correct position for closure capture variable in (*irgen).use()
   (issue20250.go) Also, evaluate rhs, lhs in that order in assignment
   statements to match noder1 (affects ordering of closure variables).

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

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

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

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

Change-Id: Ie68004d964698aea047e19e7dcd79b297e9d47ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/334733
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2021-07-16 18:30:16 +00:00
Robert Griesemer 3d8453e00e [dev.typeparams] cmd/compile/internal/types2: more consistent handling of predeclared "any"
Rather than removing "any" from the universe scope, keep it predeclared
but provide a better error message.

While at it, remove some unnecessary type assertions.

Change-Id: I10603274282ea6afc107f703ab194f32bd334dd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/334911
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-16 04:41:47 +00:00
shota3506 aa4e0f528e net/http: correct capitalization in cancelTimeBody comment
Change-Id: I7acda22c01c5350ebf5ddabb1c12af96d368de5d
GitHub-Last-Rev: 3e5c022f87
GitHub-Pull-Request: golang/go#47160
Reviewed-on: https://go-review.googlesource.com/c/go/+/334229
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2021-07-16 02:43:48 +00:00
Rob Findley 334f2fc045 [dev.typeparams] go/*: switch from ListExpr to MultiIndexExpr
When instantiating a generic type or function with multiple type
arguments, we need to represent an index expression with multiple
indexes in the AST. Previous to this CL this was done with a new
ast.ListExpr node, which allowed packing multiple expressions into a
single ast.Expr. This compositional pattern can be both inefficient and
cumbersome to work with, and introduces a new node type that only exists
to augment the meaning of an existing node type.

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

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

Change-Id: I65eb29c025c599bae37501716284dc7eb953b2ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/327149
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-07-16 00:44:40 +00:00
Matthew Dempsky 6b85a218b8 [dev.typeparams] cmd/compile: make TestUnifiedCompare insensitive to default -G level
The test currently fails if the default -G level is changed from 0 to
3, and it only makes sense to run in -G=0 mode anyway. So might as
well hard code it that way.

Change-Id: I026d25d567157df5d3f2ca3c68d31d75d9c74532
Reviewed-on: https://go-review.googlesource.com/c/go/+/334910
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-07-15 22:24:35 +00:00
Matt T. Proud 0941dbca6a testing: clarify in docs that TestMain is advanced
Beginner and intermediate Go users periodically use TestMain when
requirements do not necessitate TestMain (exceeding least-mechanism
design). This commit expands package testing's documentation to convey
that the TestMain feature itself is somewhat low-level and potentially
unsuitable for casual testing where ordinary test functions would
suffice.

Fixes #42161
Updates #44200

Change-Id: I91ba0b048c3d6f79110fe8f0fbb58d896edca366
Reviewed-on: https://go-review.googlesource.com/c/go/+/334649
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2021-07-15 20:39:22 +00:00
Bryan C. Mills 69728ead87 cmd/go: update error messages in tests to match CL 332573
I neglected to run the 'longtest' builder, and the tests
that cover the error message changed in CL 332573 apparently
do not run in short mode.

Updates #36460
Updates #42661

Change-Id: I53500ddaca8ac9f0dfaab538923b3c9a4f71665e
Reviewed-on: https://go-review.googlesource.com/c/go/+/334889
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-07-15 20:16:41 +00:00
Cuong Manh Le c1cc9f9c3d cmd/compile: fix lookup package of redeclared dot import symbol
The compiler is relying on Sym.Def field to lookup symbol package in
DotImportRefs map. But the Sym.Def field is clear whenever the compiler
finish processing a file. If the dot import happen in file A, then the
redeclaration happen in file B, then the symbol lookup in file B will
see a nil Sym.Def, that cause the compiler crashes.

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

Fixes #47201

Change-Id: I4ca1cb0a8e7432b19cf71434592a4cbb58d54adf
Reviewed-on: https://go-review.googlesource.com/c/go/+/334589
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-07-15 17:35:20 +00:00
Ian Lance Taylor 21a04e3335 doc/go1.17: mention GOARCH=loong64
For #46229

Change-Id: I54d01d90f2b0c892d76121f1350c0e8cf4b2772f
Reviewed-on: https://go-review.googlesource.com/c/go/+/334729
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-07-15 00:09:22 +00:00
Robert Griesemer 4ff0e04c2e [dev.typeparams] cmd/compile/internal/types2: embedding stand-alone type parameters is not permitted
For #47127.

Change-Id: Ie979ff56ae7c2dd0e5ce0ff39588f98ae68b5ee9
Reviewed-on: https://go-review.googlesource.com/c/go/+/334151
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14 23:33:52 +00:00
Robert Griesemer 3a047326e8 [dev.typeparams] cmd/compile/internal/types2: fix generic type indirection
Change-Id: If25ceb2aa403b94608760be331faa2aff11c47cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/333890
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14 23:33:51 +00:00
Robert Griesemer dd8bdf4a1f [dev.typeparams] cmd/compile/internal/types2: interface identity must consider full type set
There is no (obvious) way to test this at the moment because we
don't permit such constraint interfaces as ordinary types.

Change-Id: Ieeec023ed82a2c71ed50d111f26916aba4a59099
Reviewed-on: https://go-review.googlesource.com/c/go/+/333889
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14 23:33:49 +00:00
Robert Griesemer 2a8087817c [dev.typeparams] cmd/compile/internal/types2: cleanups around receiver type checks
Generic receiver types may be defined such that an instantiated
receiver ends up being a pointer type. Disallow them as we do
for non-generic receivers.

Change-Id: I6612a52615a2999375c35aa1d69ab42f37d9f55d
Reviewed-on: https://go-review.googlesource.com/c/go/+/333770
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14 23:33:48 +00:00
Robert Griesemer 95f8e64fc0 [dev.typeparams] cmd/compile/internal/types2: implement delete(m, k) where m is of type parameter type
Change-Id: Iaf33c15128af911b6101df9885cb8b5a8495b942
Reviewed-on: https://go-review.googlesource.com/c/go/+/333729
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14 23:33:47 +00:00
Robert Griesemer 5f0ea40c67 [dev.typeparams] cmd/compile/internal/types2: implement close(ch) where ch is of type parameter type
Change-Id: I45189468553e83390fd2640b5708c60a7852fbb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/333713
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14 23:33:46 +00:00
Robert Griesemer 6511922a14 [dev.typeparams] cmd/compile/internal/types2: implement ch <- x where ch is of type parameter type
For #47115.

Change-Id: Ib9c8652c0346029369735ccf7ee9098ab1ae7fd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/333712
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14 23:33:45 +00:00
Robert Griesemer ff33d3dc3a [dev.typeparams] cmd/compile/internal/types2: implement <-ch where ch is of type parameter type
For #43671

Change-Id: I7db4b3886fab44ec0de7c0935e0ab21c26e3335c
Reviewed-on: https://go-review.googlesource.com/c/go/+/333709
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14 23:33:43 +00:00
WANG Xuerui 2b00a54baf go/build, runtime/internal/sys: reserve GOARCH=loong64
Per discussion at #46229 we are taking the "loong64" GOARCH value for
the upcoming LoongArch 64-bit port. It is not clear whether any 32-bit
non-bare-metal userland will exist for LoongArch, so only reserve
"loong64" for now.

Change-Id: I97d262b4ab68ff61c22ccf83e26baf70eefd568d
GitHub-Last-Rev: ecdd8c53bd
GitHub-Pull-Request: golang/go#47129
Reviewed-on: https://go-review.googlesource.com/c/go/+/333909
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
2021-07-14 22:52:15 +00:00
Dan Scales e3e6cd3022 [dev.typeparams] cmd/compile: fix escape printout bugs for -G=3
Call SetPos() in g.expr() so it is available for any new nodes.

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

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

Change-Id: I40b9bba88027ea4f36d419e3989e7f14891bea04
Reviewed-on: https://go-review.googlesource.com/c/go/+/334609
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-07-14 21:58:10 +00:00
Rob Findley 2b10d7ff0b [dev.typeparams] go/types: export the Config.GoVersion field
Export the types.Config.GoVersion field, so that users can specify a
language compatibility version for go/types to enforce.

Updates #46648

Change-Id: I9e00122925faf0006cfb08c3f2d022619d5d54d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/334533
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-14 19:22:19 +00:00
Bryan C. Mills 60ddf42b46 cmd/go: change link in error message from /wiki to /doc.
The /doc link is currently a redirect (CL 334389),
but I plan to update it soon with a more detailed guide.

Updates #36460

Change-Id: I9e4a47ad0c8bcb7361cfa3e5b9d07ad241b13ba6
Reviewed-on: https://go-review.googlesource.com/c/go/+/332573
Trust: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2021-07-14 17:25:06 +00:00