3095 Commits

Author SHA1 Message Date
Alan Donovan
b19909b992 hash/maphash: revert purego implementation
This CL reverts the purego implementation added in CL 468795
and folds the runtime variant back into the main file.

Purego means "no assembly"; it does not mean "no linkname".
Henceforth this package will once again call runtime.memhash
unconditionally.

This was not a clean revert as there were a number of CLs since.

The motivation for this change is to avoid the maphash -> crypto/rand
dependency; see discussion on CL 657297.

Change-Id: I54ce223c5b484710ce303cdec20049146df3f8bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/761260
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2026-04-02 09:04:12 -07:00
Robert Griesemer
238d7bddeb go/types, types2: in range-over-func, the yield function cannot be variadic
Fixes #78483.
For #78314.

Change-Id: If83983c0bf79840aa02dc0d2fa8945f5e8b4e969
Reviewed-on: https://go-review.googlesource.com/c/go/+/761682
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
2026-04-01 16:39:05 -07:00
Mark Freeman
4f62ef0625 cmd/compile/internal/noder: reword comment
Change-Id: I9312f0b138e42363b611fc5193dd99a4a1f57db3
Reviewed-on: https://go-review.googlesource.com/c/go/+/761600
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2026-03-31 16:42:03 -07:00
Robert Griesemer
ed3ec75df4 go/types, types2: report an error if constant string overflows
Set a limit of 10 GiB for strings obtained via constant string addition.

Fixes #78346.

Change-Id: I35dbdff94f3ed32bf69654f4b3da435dad9f6236
Reviewed-on: https://go-review.googlesource.com/c/go/+/761300
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
2026-03-30 13:36:41 -07:00
Damien Neil
eae0bfb1b0 go/build: remove non-existent internal/itoa
This package appears to have been superseded by internal/strconv,
and no longer exists.

Change-Id: I1364aa446ece2fca7b4445fc644506136a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/758920
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2026-03-24 18:31:08 -07:00
Robert Griesemer
9f7e98d263 go/types, types2: allow promoted field names as keys in struct literals
For #9859.

Change-Id: Ie4823e726ab43fe2ce1e96c279f63dad6c1f9873
Reviewed-on: https://go-review.googlesource.com/c/go/+/751702
Reviewed-by: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2026-03-19 14:32:21 -07:00
Robert Griesemer
a6949e942c go/types, types2: handle unconstrained type parameters correctly in a few places
When iterating over a type set via a range clause, am unconstrained
type set produces a single (nil, nil) result. This was not properly
accounted for in a few places:

- In the code for the append and copy built-in, handle the (nil, nil)
  case.
- Likewise, in NewSignatureType, panic with the correct (string) error
  in this case.

Check all remaining places where we iterate over type sets with range
for correctness.

Fixes #78163.

Change-Id: If0f33f43dad59b4b5ef4c310f80522c25c6e251f
Reviewed-on: https://go-review.googlesource.com/c/go/+/755941
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2026-03-17 13:47:05 -07:00
Damien Neil
080aa8e964 net/http: use net/http/internal/http2 rather than h2_bundle.go
Rework net/http/internal/http2 to use internally-defined types
rather than net/http types (to avoid an import cycle).

Remove h2_bundle.go, and replace it with calls into
net/http/internal/http2 instead.

For #67810

Change-Id: I56a1b28dbd0e302ab15a30f819dd46256a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/751304
Reviewed-by: Nicholas Husin <nsh@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-03-12 08:13:20 -07:00
Damien Neil
afef73a5aa net/http: move DetectContentType into net/http/internal
The http2 package needs access to DetectContentType,
so move it into a common location.

For #67810

Change-Id: Ibff3d57a4931106c2f69c5717c06bd5f6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/751701
Reviewed-by: Nicholas Husin <nsh@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Nicholas Husin <husin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-12 08:10:34 -07:00
Damien Neil
93893efc69 net/http/internal/http2: make tests pass
Remove the "//go:build ignore" lines from the initial import
and make the minimal changes required for tests to pass in
the new package location.

For #67810

Change-Id: I243f4d4a2e269266786a22a7eb8fb17d6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/751700
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
2026-03-12 08:07:20 -07:00
Damien Neil
aa4370313d internal/gate: import from x/net/internal/gate
Copy the x/net/internal/gate package,
used by net/http/internal/http2 tests.

For #67810

Change-Id: I4080527ec74c57cb5c136f5701e3e76e6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/751301
Reviewed-by: Nicholas Husin <nsh@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Nicholas Husin <husin@google.com>
2026-03-12 08:06:54 -07:00
Noam Cohen
a8f99ef1f6 go/printer: use architecture-independent math for alignment decisions
The `exprList` function uses a geometric mean of expression sizes to
decide whether to break column alignment in composite literals.
Previously, this was computed using `math.Exp` and `math.Log`,
which are not guaranteed to produce bit-for-bit identical results
across CPU architectures. For example, `math.Exp(math.Log(95))`
returns exactly 95.0 on arm64 but 94.999... on amd64, which can flip
the alignment decision.

Replace math operations with approximations that are
architecture-independent. The approximations are sufficient
for this heuristic and are guaranteed to produce identical formatting
on all architectures.

Fixes #77959

Change-Id: I78d00d85fd62859803d14d619b4a45e2e5081499
Reviewed-on: https://go-review.googlesource.com/c/go/+/752862
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-11 13:27:47 -07:00
Robert Griesemer
710014bcc3 go/types, types2: implement simple generic trie
Will be used to detect overlapping field selectors in
struct literals.

Change-Id: I6f939171ba1491251489698d40123f5283602458
Reviewed-on: https://go-review.googlesource.com/c/go/+/752601
Reviewed-by: Mark Freeman <markfreeman@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-03-09 15:25:52 -07:00
Robert Griesemer
e84da0405b cmd/compile, go/*: allow generic methods starting with Go 1.27
This only changes the type checkers and tests.
Backend compiler changes are not included.

For #77273.

Change-Id: I8cf0b6fddf6afd6b08b06ba6fdf9c726af4bea8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/746820
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2026-03-09 12:16:20 -07:00
Robert Griesemer
d4ace6b007 go/types, types2: up-date testdata/manual template
This template is frequently used to create test cases.
Change the date so new tests use the correct date.

Change-Id: I83075e105b8b97c673d9ff47fb0d47e32e5184de
Reviewed-on: https://go-review.googlesource.com/c/go/+/752600
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Mark Freeman <markfreeman@google.com>
2026-03-09 11:07:18 -07:00
Alan Donovan
4e693d1ec5 go/token: add File.String method
It returns a brief, unspecified, human-readable description
of the File.

+ test, doc, relnote

Fixes #76285

Change-Id: I8b0705cf20eaac095bc9dfba7f1181774544f02c
Reviewed-on: https://go-review.googlesource.com/c/go/+/743280
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2026-02-23 07:48:58 -08:00
Robert Griesemer
06dc5db75d cmd/compile, go/*: move method type parameter checks from parsers to type checkers
The parsers (cmd/compile/internal/syntax and go/parser) always accepted
type parameters on methods for parser robustness but reported an error.

With this change, the parsers accept the type parameters on methods,
and then the type checkers (cmd/compile/internal/types2 and go/types)
complain about them.

Add test case for method type parameters when running the parsers only.
Adjust some existing test cases as needed.

This change is a necessary first step towards implementing generic
methods but does not enable them.

For #77273.

Change-Id: I291fcf0aef0c917c74b32131c88b9e4ed71c5060
Reviewed-on: https://go-review.googlesource.com/c/go/+/738441
Reviewed-by: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2026-02-19 12:22:13 -08:00
Mark Freeman
e2a34c7e9b go/types, types2: mechanically swap x.mode() == invalid for !x.isValid()
Change-Id: I2e98178a42ad225aa3803dc4ccd26d50938f29b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/742501
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
2026-02-05 14:26:01 -08:00
Mark Freeman
934a79ff2f go/types, types2: mechanically swap x.mode_ = invalid for x.invalidate()
Change-Id: I7802b10f63a52e5f864d550a7ad7678d4581a796
Reviewed-on: https://go-review.googlesource.com/c/go/+/742500
Auto-Submit: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2026-02-05 14:24:24 -08:00
Mark Freeman
cd92bae42f go/types, types2: mechanically replace read accesses to operand.mode_
Change-Id: Ib832f4f9fde45b1308208f05756960191953e8f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/742081
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-05 14:24:18 -08:00
Mark Freeman
cfe0f55571 go/types, types2: mechanically replace read accesses to operand.typ_
This provides a hook to enforce that operand.typ is only observed where
operand.mode is not invalid.

For #76110

Change-Id: I915f3ac09dc10bfe3f9f688d6190ad58e195ddcb
Reviewed-on: https://go-review.googlesource.com/c/go/+/741220
Auto-Submit: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-05 14:24:12 -08:00
Mark Freeman
fd146ff3b3 go/types, types2: mechanically rename operand.mode to operand.mode_
Change-Id: I7a978b4a448a25c596c8af346e2ebc11f0ed67e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/742080
Auto-Submit: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2026-02-05 14:00:57 -08:00
Mark Freeman
052e64e938 go/types, types2: mechanically rename operand.typ to operand.typ_
Change-Id: Iba87b8bc6188e5e784542f2c0f6f4c4cc3f70b28
Reviewed-on: https://go-review.googlesource.com/c/go/+/742022
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2026-02-05 13:43:58 -08:00
AN Long
9972154461 go/build: don't invoke go command when setting UseAllFiles
Fixes #68556

Change-Id: I36b08577243a6b3a13b3adef116411d73a2d3428
Reviewed-on: https://go-review.googlesource.com/c/go/+/700337
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-04 14:45:16 -08:00
Mark Freeman
7fd116f864 go/types, types2: add missing Named.unpack call in Checker.hasVarSize
CL 734980 swapped use of Type.Underlying() in Checker.hasVarSize for
traversal of Named.fromRHS. It forgot to call Named.unpack() before
inspecting Named.fromRHS, allowing access of unexpanded instantiated
types.

These unexpanded instantiated types are then mistakenly marked as having
fixed size, which fails assertions downstream. This change adds the
missing Named.unpack() call and swaps direct access of Named.fromRHS for
Named.rhs(), which verifies such access in debug mode.

Fixes #77382

Change-Id: I324bbbbf790f8b09e95902ebe67f775483f88417
Reviewed-on: https://go-review.googlesource.com/c/go/+/740620
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-02 15:18:11 -08:00
Mateusz Poliwczak
48788436b8 go/token: simplify fixOffset
Each time I go to definition of this I am deeply confused
at what I am looking, so let's clean this a bit with modern Go.

Change-Id: I8f44e78f0cdde9b970388f9b98a2720e6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/738341
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2026-01-29 13:17:22 -08:00
Mateusz Poliwczak
2bd7f15dd7 go/scanner: document implicit semicolon in multiline comments
Updates #54941

Change-Id: I62406c53b5b27742003098c77cfba0a96a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/738720
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-01-28 22:44:54 -08:00
Mateusz Poliwczak
74c909b2c5 go/parser: use (*Scanner).End instead of scannerhooks
Also drop the scannerhooks code, as it is now unused.

Updates #74958
Updates #76031

Change-Id: I5a0cb8a7fe954e40ce40b8406aed0d3f6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/738701
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-01-28 22:44:38 -08:00
Mateusz Poliwczak
15882523a1 go/parser: use (*Scanner).End in error testing
Updates #74958

Change-Id: I43dcbff6ec828bddf157b2e6ec80df526a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/738700
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-01-28 22:44:26 -08:00
Mateusz Poliwczak
3c924059e6 go/scanner: add End method to Scanner
Fixes #74958

Change-Id: I50ef64ae9ae6a762a7aada3d29914bae6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/738681
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-01-28 22:44:07 -08:00
Mark Freeman
ffb50fb716 go/types, types2: rename Named.finite to Named.varSize
Change-Id: I81646c2753c2e44953b116138cb41d41a011ff08
Reviewed-on: https://go-review.googlesource.com/c/go/+/739561
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2026-01-27 08:26:32 -08:00
Mark Freeman
a977717393 go/types, types2: add check for map value completeness in IndexExpr
An index expression can also go from map[K]V to V. Since V could be
incomplete (due to some admittedly contrived syntax), we need a
check.

Change-Id: I03ffbfc0e5bcc9129591d60dfbaa5fafcf8fb183
Reviewed-on: https://go-review.googlesource.com/c/go/+/737620
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
2026-01-27 07:52:07 -08:00
Mark Freeman
8ca47fab42 go/types, types2: replace pendingType with completion check
This change establishes the invariant that Underlying() cannot observe
a nil RHS for a defined type, unless that type was created by go/types
with an explicitly nil underlying type.

It does so using isComplete, which is a guard to check that a type has
an underlying type. This guard is needed whenever we could produce a
value of a defined type or access some property of a defined type.

Examples include T{}, *x (where x has type *T), T.x, etc. (see CL
734600 for more).

The pendingType mechanism to deeply traverse values of a defined type
is moved to hasVarSize, since this is only truly needed at the site
of a built-in such as unsafe.Sizeof.

This ties cycle detection across value context directly to the syntax,
which seems like the right direction.

Change-Id: Ic47862a2038fb2ba3ae6621e9907265ccbd86ea3
Reviewed-on: https://go-review.googlesource.com/c/go/+/734980
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
2026-01-27 07:52:02 -08:00
Mateusz Poliwczak
f809faeb8e go/scanner: clear all fields after Scanner reuse
We were missing s.nlPos = token.NoPos in Init, but while we are here
let's make it less likely to hit this it in future.

Change-Id: Ief4c0ba2cf97bc556d901eabc8e172406a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/738680
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2026-01-26 07:58:30 -08:00
Nicholas S. Husin
ca5ffe0092 all: update vendored dependencies
This CL does the following:

1. Bundles up golang.org/x/net/internal/httpsfv since h2_bundle.go now
relies on it.
2. Modifies h2_bundle.go import mapping to account for httpsfv package.
3. Updates all vendored dependencies using
golang.org/x/build/cmd/updatestd.

For #75500

Change-Id: Ia2f41ad606092fe20b62f946266190502b146977
Reviewed-on: https://go-review.googlesource.com/c/go/+/738621
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-01-23 11:09:53 -08:00
Robert Griesemer
6d89ab44cc go/types, types: flip field/method selection logic inside out (cleanup)
By selecting on *Var/*Func first, the field/method selection logic
becomes a bit cleaner, clearer, and a little bit simpler.

No functional changes.

Change-Id: I9860f98d52779b0f7ce4484ea77e74a3667d9e6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/738080
Reviewed-by: Alan Donovan <adonovan@google.com>
Commit-Queue: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2026-01-23 09:18:50 -08:00
Robert Griesemer
6edb9f9c51 go/types, types2: remove support for gotypesalias GODEBUG flag
For #76472.

Change-Id: Ia51b41639637b1de916625e73c26f625382be305
Reviewed-on: https://go-review.googlesource.com/c/go/+/736441
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Commit-Queue: Robert Griesemer <gri@google.com>
2026-01-22 21:37:55 -08:00
Robert Griesemer
2d37c20778 go/types, types2: better error when selecting field on type rather than value
Fixes #6814.

Change-Id: I659670998f8e89400d03d40189e8c54f7e705cdc
Reviewed-on: https://go-review.googlesource.com/c/go/+/738040
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2026-01-21 16:01:08 -08:00
Alan Donovan
532e320349 go/types,cmd/compile/internal/types2: better diagnostic for type shadowing
This change causes the "x is not a type" diagnostic to describe
x's actual kind, helping to reveal when shadowing is at work.

(The kind description could improve other errors too.)

Fixes #76877

Change-Id: Ia3484998bb384ff570c20b6792cf8461c60aa38c
Reviewed-on: https://go-review.googlesource.com/c/go/+/731180
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2026-01-15 15:10:27 -08:00
Sean Liao
d46c58debb go/doc: link to struct fields in the same package
This collects up any struct direct field references
for linking. It does not attempt to do any validation
of embedded field conflicts as in CL 510315.

For #61394

Change-Id: I57dc0a0e8a71ce0bcb4e6c0963f459f76a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/729980
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Matloob <matloob@google.com>
2025-12-19 13:19:23 -08:00
Sean Liao
ea1aa76554 go/doc: exclude examples with results
Fixes #36185

Change-Id: I7634744e62e00023367ed48a4700b61a6a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/729902
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-12-16 12:37:31 -08:00
Sean Liao
e8a83788a4 go/doc: reuse import name logic for examples
Examples resolved imports based on just the path name,
but this doesn't work for go-name or modules on v2+.

Updates #12794
Fixes #45110
Fixes #56740
Fixes #62059

Change-Id: I8c71b1e5311df04bccbdf319d759d3176a6a6964
Reviewed-on: https://go-review.googlesource.com/c/go/+/728280
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2025-12-12 09:04:46 -08:00
Mark Freeman
2622d2955b go/types, types2: remove indirection of Named.finite
This field is now guarded by a state bit. The "unknown" state is hence
indicated by absence of that bit.

Change-Id: I9605538f089dd4fd638e5f0f416cd4b8737b6f88
Reviewed-on: https://go-review.googlesource.com/c/go/+/729041
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-12-11 10:11:13 -08:00
Mark Freeman
72c83bcc80 go/types, types2: put Named.finite behind Named.mu
This change adds another leaf state to named types which indicates
whether the type's size finiteness is known.

Without this, writes to Named.finite can result in a clobbered value.
While benign in terms of functionality, it triggers the race detector.

Fixes #76773

Change-Id: I2ac3d8d6f8be55a8120598daecb3e78aa7df5f30
Reviewed-on: https://go-review.googlesource.com/c/go/+/729021
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
2025-12-11 08:18:30 -08:00
Mark Freeman
1274d58dac go/types, types2: add check for finite size at value observance
Each type must be representable by a finite amount of Go source code
after replacing all alias type names, value names, and embedded
interfaces (per #56103) with the RHS from their respective declarations
("expansion"); otherwise the type is invalid.

Furthermore, each type must have a finite size.

Checking for finite source after expansion is handled in decl.go.
Checking for finite size is handled in validtype.go and is delayed to
the end of type checking (unless used in unsafe.Sizeof, in which case
it is computed eagerly).

We can only construct values of valid types. Thus, while a type is
pending (on the object path and thus not yet valid), it cannot construct
a value of its own type (directly or indirectly).

This change enforces the indirect case by validating each type at value
observance (and hence upholding the invariant that values of only valid
types are created). Validation is cached on Named types to avoid
duplicate work.

As an example, consider:

  type A [unsafe.Sizeof(B{})]int
  type B A

Clearly, since there are no aliases, A and B have finite source. At the
site of B{}, B will be checked for finite size, recursing down the
values of B, at which point A is seen. Since A is on the object path,
there is a cycle preventing B from being proven valid before B{},
violating our invariant.

Note that this change also works for generic types.

Fixes #75918
Fixes #76478

Change-Id: I76d493b5da9571780fed4b3c76803750ec184818
Reviewed-on: https://go-review.googlesource.com/c/go/+/726580
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
2025-12-09 08:51:02 -08:00
Cherry Mui
c456ab7a30 [dev.simd] all: merge master (a33bbf1) into dev.simd
Merge List:

+ 2025-12-08 a33bbf1988 weak: fix weak pointer test to correctly iterate over weak pointers after GC
+ 2025-12-08 a88a96330f cmd/cgo: use doc link for cgo.Handle
+ 2025-12-08 276cc4d3db cmd/link: fix AIX builds after recent linker changes
+ 2025-12-08 f2d96272cb runtime/trace: update TestSubscribers to dump traces
+ 2025-12-08 4837bcc92c internal/trace: skip tests for alloc/free experiment by default
+ 2025-12-08 b5f6816cea cmd/link: generate DWARF for moduledata
+ 2025-12-08 44a39c9dac runtime: only run TestNotInGoMetricCallback when building with cgo
+ 2025-12-08 3a6a034cd6 runtime: disable TestNotInGoMetricCallback on FreeBSD + race
+ 2025-12-08 4122d3e9ea runtime: use atomic C types with atomic C functions
+ 2025-12-08 34397865b1 runtime: deflake TestProfBufWakeup
+ 2025-12-08 d4972f6295 runtime: mark getfp as nosplit
+ 2025-12-05 0d0d5c9a82 test/codegen: test negation with add/sub on riscv64
+ 2025-12-05 2e509e61ef cmd/go: convert some more tests to script tests
+ 2025-12-05 c270e71835 cmd/go/internal/vet: skip -fix on pkgs from vendor or non-main mod
+ 2025-12-05 745349712e runtime: don't count nGsyscallNoP for extra Ms in C
+ 2025-12-05 f3d572d96a cmd/go: fix race applying fixes in fix and vet -fix modes
+ 2025-12-05 76345533f7 runtime: expand Pinner documentation
+ 2025-12-05 b133524c0f cmd/go/testdata/script: skip vet_cache in short mode
+ 2025-12-05 96e142ba2b runtime: skip TestArenaCollision if we run out of hints
+ 2025-12-05 fe4952f116 runtime: relax threadsSlack in TestReadMetricsSched
+ 2025-12-05 8947f092a8 runtime: skip mayMoreStackMove in goroutine leak tests
+ 2025-12-05 44cb82449e runtime/race: set missing argument frame for ppc64x atomic And/Or wrappers
+ 2025-12-05 435e61c801 runtime: reject any goroutine leak test failure that failed to execute
+ 2025-12-05 54e5540014 runtime: print output in case of segfault in goroutine leak tests
+ 2025-12-05 9616c33295 runtime: don't specify GOEXPERIMENT=greenteagc in goroutine leak tests
+ 2025-12-05 2244bd7eeb crypto/subtle: add speculation barrier after DIT
+ 2025-12-05 f84f8d86be cmd/compile: fix mis-infer bounds in slice len/cap calculations
+ 2025-12-05 a70addd3b3 all: fix some comment issues
+ 2025-12-05 93b49f773d internal/runtime/maps: clarify probeSeq doc comment
+ 2025-12-04 91267f0a70 all: update vendored x/tools
+ 2025-12-04 a753a9ed54 cmd/internal/fuzztest: move fuzz tests out of cmd/go test suite
+ 2025-12-04 1681c3b67f crypto: use rand.IsDefaultReader instead of comparing to boring.RandReader
+ 2025-12-04 7b67b68a0d cmd/compile: use isUnsignedPowerOfTwo rather than isPowerOfTwo for unsigneds
+ 2025-12-03 2b62144069 all: REVERSE MERGE dev.simd (9ac524a) into master

Change-Id: Ia0cdf06cdde89b6a4db30ed15ed8e0bcbac6ae30
2025-12-08 17:41:05 -05:00
David Chase
144cf17d2c [dev.simd] simd, cmd/compile: move "simd" to "simd/archsimd"
Also removes a few leftover TODOs and scraps of commented-out code
from simd development.

Updated etetest.sh to make it behave whether amd64 implies the
experiment, or not.

Fixes #76473.

Change-Id: I6d9792214d7f514cb90c21b101dbf7d07c1d0e55
Reviewed-on: https://go-review.googlesource.com/c/go/+/728220
TryBot-Bypass: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-12-08 13:57:44 -08:00
cuishuang
a70addd3b3 all: fix some comment issues
Change-Id: I5dec35b1432705b3a52859c38e758220282226af
Reviewed-on: https://go-review.googlesource.com/c/go/+/726700
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sean Liao <sean@liao.dev>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-12-05 07:30:36 -08:00
Alan Donovan
fa30b68767 go/{ast,doc}: update BasicLit.ValueEnd as well as ValuePos
For #76395

Change-Id: Ie2ad715a05cb298b08667cfe8a8394f1dfa3936c
Reviewed-on: https://go-review.googlesource.com/c/go/+/722880
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-12-03 06:50:50 -08:00
Mark Freeman
c048a9a11f go/types, types2: remove InvalidTypeCycle from literals.go
Both CL 722161 and CL 724140 implement a more general solution to
detecting cycles involving values of a type on the object path.

The logic in literals.go was intended to be a stop-gap solution and
is no longer necessary.

Change-Id: I328c0febf35444f07fc1894278dc76ab140710bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/724380
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
2025-11-26 16:20:21 -08:00