- leave type bounds away if empty (interface); don't write "any"
- boundle type parameters with the same type type bound
- simpler code for error message cleanup
Change-Id: I8c1b662479de185b2ebae47ed1d16482253dfe03
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go2-dev/+/710076
Reviewed-by: Robert Griesemer <gri@google.com>
- store a *Named type in both caches
- update local cache also when we have a global cache hit
Change-Id: If4ab24a0c24d21f425a76dc51e4ec2ed495b26e4
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go2-dev/+/710128
Reviewed-by: Robert Griesemer <gri@google.com>
Instead of creating a new instantiated type name "name<T1, T2...>"
keep the regular name for the corresponding type object since
these newly created types are never declared. This eliminates
the need to clean up the names (remove the <>'s) before they can
be used.
When printing a named type, simply decide what to print depending
on whether it is instantiated or not.
When looking up an instantiated type, simply create the instantiated
type name string for use in the (local and global) type caches.
Change-Id: I4b20d09ec64d8deefccdd338ffb2f78fdfd2101e
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go2-dev/+/710062
Reviewed-by: Ian Lance Taylor <iant@google.com>
Per the draft design:
In a generic function body all method calls will be pointer method calls.
If necessary, the function body will insert temporary variables, not seen
by the user, in order to get an addressable variable to use to call the method.
When checking if a concrete type argument satisfies its type bound, assume
that concrete type is the type of an addressable value.
Change-Id: I9d40138755c38330448c010994b95a82f38e60e0
- added Error.Full and Error.FullError which provide the full error
message, possibly containing internal details
- Error.Msg and Error.Error provide a user-friendly error message
Change-Id: Id3044165331af71be31ef423cd2c9b8fe28accbd
Since the type bound of a type parameter is an interface, no method
is found if the receiver is a pointer to a type parameter (pointers
to interfaces have no methods).
Ignore the indirection in this case.
Change-Id: Ie2af78b4cfb2f70b5d4f1d2afc631716a10ff7d9
Pointer designations were not recognized nor supported.
Now we recognize them and report an error until type-checking
can handle them.
Change-Id: I0deed536aa03c06c3e9ec60a5c2e186e916b970f
Until now, types of type lists in interface types were collected in
a single expression list "Types". This made it not possible to gofmt
such interfaces while preserving the original layout of type lists.
This change represents types of type lists as part of an ast.FieldList.
The ast.InterfaceType.Methods field list now represents embedded interfaces,
methods, or type list types through ast.Fields. This preserves all position
information and thus permits accurate gofmt-ing.
The new representation is as follows: For an ast.Field f, if
- len(f.Names) == 0 : f.Type is an embedded interface
- f.Names[0].Name == "type": f.Type is a type of a type list
- otherwise : f represents a method
Since "type" is a keyword, a Go field name cannot be "type".
Fields of types of type lists that share the same "type" keyword
in the source share the same f.Names[0] identifier (named "type"),
and the position of that identifier is the position of the "type"
keyword in the source.
Related changes:
- Adjusted go/parser to build the new representation.
- Adjusted go/printer and implemented formatting of type lists.
(This is still not quite correct if there are comments, but
that is fine-tuning).
- Adjusted go/types to work with the new representation.
- Implemented SplitFieldList and MergeFieldList in go2go
translator to easily switch between old and new representation.
- Updated documentation.
Change-Id: I016e2ce5949bfe294509d703156c41d42cf7084e
Type unification now happens through the new unifier code.
We can revert the functionality of Checker.identical back
to its original purpose of type comparison. This change
should make identity comparison faster again.
Change-Id: I844515b5f20a890152a0a5436f04c553b3b722e5
- Implemented bidirectional unifier as a stand-alone mechanism
separate from Checker.identical0.
- Use it instead of Checker.identical0 where we need unification.
- Missing: Bidirection functionality not fully implemented because
we don't use it yet, but the basic outline is present.
Change-Id: I1666c9e4c9094eda749084bb69c700f1b5e879bb
Cases such as
func f(type T)(x T) {
f(x)
}
can now be type-checked. For more examples see examples/functions.go2
in the go/types directory.
Change-Id: Id661c84f086cc8ee45ec372ac4af543e68bebe8a
Contract embedding is reduced to interface embedding. When embedding
interfaces:
1) use the correct interface to embed; and
2) don't leave type bounds residue on the incoming type arguments
of the embedded interface/contract as those are also the type
parameters of the embedding (outer) interface/contract.
Also:
- For now, print "any" instead of "interface{}" (empty interface)
when printing type parameter lists to reduce clutter. Eventually
we should not print anything for empty interface bounds, but we
first must also group type parameters with the same type bounds.
- Print the type parameter subscript in type parameter lists to
make it clearer which type parameter we are referring to.
Change-Id: Ic83516096387d0f512c4c76a8a8fe849d51e033a
The comparable contract defines a magic method "==" which
enables comparisons with == and != . Comparable types
automagically implement this method.
TODO: If a type is not comparable but a comparable type is
expected, the error message can be confusing (missing ==
method).
Change-Id: Ie0d89b87c36d83549f7d869c18dd9786151adbae
More precisely, de-parameterize the corresponding interfaces when
embedding them in the corresponding type bounds (interfaces) for
the embedding contract. This prevents the embedded (and already
instantiated) interfaces from being instantiated again when the
outer interface is instantiated and avoids breaking an assertion.
See also the test case in testdata/issues.go2 for more details.
Change-Id: I70c9354849eda0c8a36905d0b80f4d3031542f30
We can now translate code that use type inference when calling generic
functions. A couple of test cases were adjusted to use it.
Change-Id: I53c2f3dd8f9fcdb44b4a8f592acee1a19ff46f22
In api.go, introduce a new type `Inferred` which collects type arguments
and signature in one place and which can be extended if need be.
Change-Id: I014dd52641843e85ad408fdaa07eda121cf1c41c
Original code by iant@. Slightly streamlined and fixed a bug in the
process (if there is a type error in the contract, we only must "use"
the type arguments if they exist in the first place).
Change-Id: Id404d2cd4fd081b9a8053e194bf643593093e397
Assertions/type switches that are guaranteed to fail on generic
types are not permitted (in contrast to regular type assertions
and type switches).
Change-Id: Iaa5b96f094585cb206fdadaa501445f96f26c166
Instead of rewriting the underlying AST for a receiver type in place,
explicitly pass the rewritten AST to Checker.collectParams.
Also, better comments in various places.
Change-Id: If64e80b2c6b4b57477a4a0bf87caaa2f4ea1bf21
For symmetry with embedding in structs and interfaces.
Fixed an incorrect error message print in the process.
Change-Id: I295685438a22971edc610e6c51cfefd286eaffba
To be able to distinguish between a named field with a parenthesized
type `foo (T)` and an embedded parameterized type `foo(T)` in structs
we permit the use of parentheses in embedded types. For instance, the
latter example will need to be written as `(foo(T))`.
The parser now accepts any parenthesized embedded type liberally
and assumes that type-checking makes sure only permissible types
are accepted. As a result, parsing of field declarations is now
massively simpler. Also, removed an unused function.
The type-checker now complains about invalid embedded types (as
opposed to an invalid AST); it also now accepts embedded parameterized
types.
Change-Id: Ib8c6cbea9a0b739f66ba266fb5f8b71f91b7b64e
Instead of passing around a type parameter list and type arguments,
create a substitution map from them and use that map instead.
Change-Id: Ia4a041d95bfaa98888c9c06812d33b3d2a79227d
Make sure that a generic signature is not generic anymore
after instantiation. Update various related comments.
Change-Id: I2ac81037e570dc3a96c138b85529f3d86030776a
Simplifies Checker.typeDecl. Also, methods can only be added to
top-level types; no need to try to collect them for local types.
Change-Id: I05b926df7ffa70c32c1dd5faed3c68617be8f270
Make sure receiver type and actual receiver argument
match in "pointer-ness" before attempting to infer
any receiver type parameters.
Change-Id: Ie28004ce42ecef46e348424140b8d0c65e37cdaa
Added an accessor function to go/types:
// TParams returns the type parameters of the named type t, or nil.
func (t *Named) TParams() []*TypeName { return t.tparams }
Change-Id: Ife2322c73dd6eaecaed42655a57a37541661d1ed
Just store the error in the translator struct, rather than always
checking for an error and returning it up the stack.
Change-Id: I38ea2a282f61457eea123f852d9daf9337bcf9b8
Good enough to run this program:
package main
import "fmt"
func Print(type T)(s []T) {
for _, v := range s {
fmt.Println(v)
}
}
func PrintInts(s []int) {
Print(int)(s)
}
func main() {
PrintInts([]int{1, 2})
}
Change-Id: I5ac205138085a63e7075b01ca2779b7eb71f9682
Adds a new command go2go, invocable after installation as "go tool go2go".
The go2go command supports build, test, run, and translate subcommands.
These will translate .go2 files to .go files.
No actual translation is done yet; the files are simply rewritten.
So this is a framework that works if the .go2 files are pure Go 1 code.
Change-Id: I8183fd276c4c87577c428794fb87e8dde1fa398d
TODO
- some channel errors are not reported for generic variables
- error messages should be better
Change-Id: Ie388d6811b605645ea092481eee3a850c7ceb77b
Contract instantiation (= contracts with explicit type
arguments) should work now but has some implementation
restrictions:
- The type arguments provided to a contract must be
type parameters from the type parameter list using
the contract or the type parameter list of the en-
closing contract (in case of contract embedding).
- Each type argument may be used at most once per
contract expression.
Change-Id: Ia9f9d81e95d84f11ff3821b9f17b74eadab201f8
The typestring for embedded fields in structs was changed
by 8d30bd752d4 (type checking of function type parameters)
but this test was not updated.
Change-Id: I0d9438e3000939de09aa298c33ad1e9604a59fe8
Interface.is already takes care of iterating through all types of
a generic type bound; use it instead of writing custom loops each
time.
Change-Id: Ie0f91b27e5a7b65ea85a8c3847a954db1e9f24fe
This enables the distinction between a method M(int) and an
embedded instantiated (parameterized) interface (M(int)).
Change-Id: I150d1b1cd53a2b14ddc0ad6336d84078fcb41ad6
This simplifies the use of missingMethod again but moving the lazy
instantiation of methods into missingMethod. Method comparison now
also takes method type paramaters into account.
This change enables the first examples of parameterized methods
to type-check.
Change-Id: I4c629fb7b1f8959184c6ce5196365893d11b197d
Fixes bug with generic min being accepted even though the contract
or interface bound doesn't enumerate any types (or is missing).
Change-Id: Icdfc62fbd2b73ece397d5b5f1ebe27e52ed9b32f
This step further consolidates all parameter types (except for the
receiver) in an ast.FuncType which now matches more closely the
representation of a types.Signature. As a result, fewer parameters
need to passed around because we can just use an *ast.FuncType or
a *types.Signature instead.
As an immediate (and implicit) consequence, parameterized interface
methods now type-check. (But we cannot yet "implement" them with a
matching concrete type.)
Change-Id: I2ea24694ade9838488625ffec48d5e98070d1006
This is a generalization of type parameters to methods.
Being able to type-check them (even if we don't have an
idea how to actually implement such methods) is likely
going to inform the structure the type-checker: If the
code is organized correctly, the generalization should
mostly just work (and consist of the elimination of
extra checks).
So far, this first step only exposed some minor scoping
issues (where does the scope of type parameters start).
Change-Id: I8658ea8d1876a0ce9c62c0e9a7e943301e9cc19d
This follows the approach used for methods, but there is no error
reporting yet if a type is (explicitly) declared multiple times in
an interface.
Change-Id: I52428174ae278577a7c538b0817c6fb7af1c369e
Type parameters are now collected as part of signature type
checking, as they are part of the type not the object. This
opens the door to more uniform handling of type parameters,
also for concrete methods and interface methods (future use).
Cleaned up confusion between Signature.mtparams and tparams:
tparams are explicitly declared function type parameters.
mtparams is gone and replaced with rparams which are the
receiver type parameters used in the function.
Various related cleanups.
Change-Id: Id8422b57cc8fbc18ffdca12a69d890aef83c3f80
A signature that's instantiated but doesn't have any incoming
or result (value) parameters doesn't get a copy automatically.
This leads to bugs because the instantiated signature doesn't
lose its type parameters when it should.
Make a copy outside for now, this fixes some (but not all cases)
and added test cases.
Also, factored out printing of type parameters in type printing.
Change-Id: I0ec3a4226c7473cddfb16704a2218992dd411593
This change completes the prior change by adjusting the go/types
implementation accordingly. As a consequence, contracts may now
not occur in type context anymore and errors are reported if they
do.
With this change, all tests pass again.
Change-Id: Id984b3d24b7cb6ff2fceb74fd3c33fd0af91fdce
Progress snapshot.
This change makes a contract declaration a proper declaration (as it is
envisioned in the design draft). Specifically, contracts cannot be used
in type position anymore, and a contract declaration is not treated as
a type declaration with the type being a contract.
The change has not been pushed through go/types yet; this change will
temporarily brake go/types.
Change-Id: Ia4034caebab07dac449a02cdd362d6ce5d61c4a3
Once a generic function is instantiated, it's not generic anymore.
Also: Added various additional test cases.
Change-Id: Ic2304b6c252cfdf41e526825dda64b8a77023d47
The new lazy method substitution code seems to work. The bug was
in the test, not in the implementation!
Change-Id: I39794743a01e9725d57f49ccd7c3751376cd01d6
When instantiating a type, we should also instantiate its methods (at least their
signatures) so that they have the correct type when being looked up. Unfortunately,
methods may not yet be type-checked; and worse, when we type-check them, typing
their receiver means instantiating that type again which would require updating
(= instantiating) the methods...
Instead, we keep the original list of methods (*Funcs) with each (named) type
and only update the method signatures when looking them up. The problem with this
approach is that we need to know with which values to substitute the method (i.e.,
receiver) type parameters, and this is currently not working.
Change-Id: Ie1835919dc8bfb8161a6a9e3d784c3bbbeb958c4
This CL introduces an update mechanism to customize method signatures
with the correct type parameters before comparing them for equality.
The mechanism is not correctly used, yet.
Change-Id: Ib88af88e151578a3fb3a648ed70d3f462a936c9b
When type-checking contracts, construct a parameterized named
interface for each of the contract parameters. Use those iterfaces
as type bounds for the type parameters.
This simplifies and cleans up the implementation.
Change-Id: I688e38542fa7fa83dd436439dd9ebe35af2f0458
Context-specific customization of parameterized interface methods of
type parameter bounds is missing; as a result some of linalg.go2 fails.
Change-Id: I3e749ee040d2b3ae8f73ae26680984bc1b4b79ef
If the type argument is itself a type parameter, we must use that
type parameter's bound to check against the bound of the type
parameter matching the type argument.
Change-Id: If5128115a9fc10af8163c37b1f75645447ead766
- type instantiations checks parameter count
- better positions for error messages
- removed some (now) dead code
Change-Id: Icf70642bbfd4e45a7762b002ea94704dc3d56475
This (temporarily) disables the use of recursively defined
generic types w/o repeating the type arguments, but such
type definitions need some more (type-checking) love anyway
before all conditions are checked.
Change-Id: I173f5ce2296b1c484ac95a3a887812c0b1f88245
- print type bounds when printing function signatures
- store (named) tyep bound rather than underlying type
- first example using parameterized interface type bound working
Change-Id: Ic7110039d1e09838c8f33040e887e6a4f038d75d
Accept (parse and type-check) parameterized interfaces with literal
type constraints, as in contracts. For instance, instead of
contract C(T) {
T add(T) T
T int, string
}
one can write
type C(type T) interface {
add(T) T
type int, string
}
Their use as type bounds still needs some work, though.
Change-Id: I9d59681dc0ba38054ee5627be141fc6e8a78381b
- set correct token position for ast.ContractType
- print "best effort" interface position in "complete interface" traces
- don't print trace output for types that are already set up
- print contract "signtature" when printing Contract type
Also: rebased on top of today's master branch
Change-Id: I6a528ce51a4152c25ad5d83ad52e01df8e89d283
This change expands type inference to parameterized named types
and clarifies handling of type parameters during type inference
(specifically, an inferred type may be a type parameter itself).
The change also implements method selectors with parameterized
receiver types by using type inference to deduce the receiver
type parameters.
Add more tests and enable many disabled tests that now work
correctly.
Change-Id: I8e10f9166fec9a8454f14b8fb089230c70422a1b
Also: disabled aggressive rewriting of methods upon type instantiation
(Need to first figure out what we really need to do.)
Change-Id: I6fba78d60963534ebfe130164058ac1fbed7e5a3
A parameterized named type is in one of two states: not yet
instantiated, or instantiated. It may be instantiated with
any type, including (outer) type parameters. An instantiated
parameterized type may needs its type parameters substituted
if it is part of an enclosing type (or function) that is
instantiated.
A Named type has an extra field targs which is set to the
type arguments if the type is instantiated.
As a result, we don't need a representation for (partially)
instantiated parameterized types anymore: the Parameterized type
is now unused (but still present in the code).
Added a unique id field to TypeParam types so they can be
printed with a unique name. This permits the creation of a
unique type name for instantiated types which then can be used
for hashing that type name.
Also, made interfaces as type bounds work in more cases.
A handful of places (in testdata/map.go2, map2.go2) are broken
(commented out) and need investigation.
Change-Id: I137d352b419b2520eadde1b07f823375e0273dab
Always accept them but complain if they are not permitted.
The analogous parser check was lost in a recent change.
Also: Fix index computation in collectTypeParams.
Change-Id: I7cb89944984df6dadd7f603b56f0c3941d60f7c5
- implemented for comparisons for now
- can type-check generic min
- also: rebased on top of Go tip
Change-Id: Id35582a59c4cddcb2b4ae9c7d7154ef8e41580ab
Also: Recognize method expressions with parameterized receivers
and report an error for now (not implemented yet).
Change-Id: I96405b2b739d8e9fff6e9840347d3e78bfe8b6ec
To make the import work, the import needs to be changed into
`import "./chan"`, the file testdata/chans.go2 needs to be
copies into a new directory testdata/chan and the file must
be renamed to chans.go.
But this exposes some problem with instantiating parameterized
types with other type parameters. Delaying this for now.
Change-Id: I1cd784fb89c2374131f3b1105493492eb0189abc
... and various related smaller fixes
We can now type-check the slices, chans, and maps
examples from the design doc (with the maps example
prodcing an error because importing chans doesn't
work yet). Progress!
Change-Id: Ifc00359a9a1cdad3bde1659a7de2028ac2544469
- moved type parameter collection out of resolver and into decl phase
- collect (meta-) type information (contracts) for type parameters
- first cut at checking contract satisfaction (methods only for now)
Change-Id: I46707969a172423738171aaea9d5282fb4b25a44
- collect contract methods in respective interfaces
- basic checking on contract type constraints
Contracts are not yet tested against or used to type check
function bodies.
Change-Id: I13b00c44524e599f92f1ba5b4b5d6734e2bf22e1
- type parameters can be printed
- empty contracts can be printed
- contract constraints are missing (only started)
Change-Id: I787898203aeb064b0b2ac49a7b858313cee5f45b
Also: Added -h flag to test framework; setting -h causes a panic when
an error is reported (for debugging).
Change-Id: Ib45d4ef38769f2ecdd3ce53fa3aed9fd99ef6bc8
Next known issue:
type List(type E) []E
var _ List(List(List(int))) = [](List(List(int))){}
This won't work because the RHS's composite literal type
is not fully instantiated - it has non-instantiated elements
which are ignored by Checker.instantiatedType. We could just
call Checker.subst w/o any parameters and have it walk the
incoming type and instantiate any element Parameterized types
but that is expensive and also appears to lead to stack over-
flow. Need to investigate.
Change-Id: I80bd09ab5f06e3991f198965424ce3322c7d6402
testdata/typeinst2.go has some complex examples that pass now.
But code elsewhere seems broken. go test has some issues at the
moment. Committing anyway to not lose the snapshot.
Change-Id: Id8f753a7b098405e2580a45ca1707ef6476c198e
- use the right type when instantiating a type
- substitute defined types when underlying types are changing
- improved printing of parametrized types
- improved printing of instantiated types
- more top-level trace output
Change-Id: Ie8a65c9cc51e80925d3f580f54dcc6c0b5abe4c6
- move init and method parameter checks to resolve phase as well
- more consistent error messages
- more tests
Change-Id: I6cb147b35385541ca5d7d7e3f87159df84cced76
Updated go/ast and go/parser. go/types doesn't process the
new data structure yet and is missing a good type representation
of contracts.
Change-Id: I101f7c9e98008840dd1edb55404bb97db5a66ccd
Additionally, simplify the syntax for contracts specified in a
type parameter list: It is now not possible to provide explicit
type parameters to a contract in a type parameter list - they
are always implicit. For instance
func f(type P1, P2 C(P1, P2)) ...
must be written as
func f(type P1, P2 C) ...
If a different order or different types are desired for C,
a new "intermediate" contract must be declared, as in
contract C'(A, B) {
C(B, int) // here we allow type parameters
}
func f(type P1, P2 C')
This simplification will remove confusion if we decide to
allow individual contracts in type parameter lists, such as
func f(type P C, P1, P2 C') ...
In this case, C accepts one type parameter (and applies to P),
and C' accepts two type parameters and applies to P1 and P2.
The simplification avoids questions such as whether this code
should be permitted:
func f(type P C(P2), P1, P2 C'(P, P1)) ...
(i.e., can pass P2 to C, or P1 to C', etc.)
This change switches parsing back to using () parentheses for
type parameters. The parser now also accepts contracts in
parametrized type declarations, and top-level declared
contracts as defined in the design draft:
contract C(T1, T2) { ... }
(Internally, they are mapped to an ast.ContractType as before.)
Added more tests, incl. map.go2 from the design draft, and removed
some unused parser functions.
Passes parser and types tests.
Known issue: Composite literals with instantiated composite literal
types are not recognized properly: T(P){...} fails to parse.
This change implements parsing of contracts based on the
most recent design (using a combination of methods and
explicit basic types as well as the short-hand notations
0, 0.0, 0i, ==, and !=). At the moment, a contract is
considered a "type" and declared as such:
type C contract(T1, T2) { ...}
This change also implements parsing of type instantiations
and type parameters for type declarations, using both the
() parentheses and [] brackets (if the flag useBrackets is
set in parser.go).
Not all parsed data structures are set up correctly in the
AST yet. The parser and ast tests pass.
Change-Id: I11ce64ad49e404c5a66ce6623edc8313e803e135
This change implements parsing and type-checking
of parametrized functions (without contracts).
Type-checking includes checking of generic function
calls using explicit type parameters as well as
implicit type parameters inferred from the actual
arguments.
Change-Id: I03c9c6912aa1e2ac79d9c5125fd5ac72df4e808a
This alert is triggering occasionally. I've investigated the
collisions that happen, and they all seem to be pairwise, so they are
not a big deal. "pairwise" = when there are 32 collisions, it is two
keys mapping to the same hash, 32 times, not 33 keys all mapping to
the same hash.
Add some t.Logf calls in case this comes back, which will help isolate
the problem.
Fixes#39352
Change-Id: I1749d7c8efd0afcf9024d8964d15bc0f58a86e4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/237718
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Support for linux/386 was added to Delve in version 1.4.1, but the
version of Delve currently installed on the linux-386-longtest
builder is 1.2.0. That isn't new enough, which causes the test
to fail. Skip it on that builder until it can be made to work.
The only reason it used to pass on the linux-386-longtest builder
before is because that builder was misconfigured to run tests for
linux/amd64. This was resolved in CL 234520.
Also improve internal documentation and the text of skip reasons.
Fixes#39309.
Change-Id: I395cb1f076e59dd3a3feb53e1dcdce5101e9a0f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/237603
Reviewed-by: David Chase <drchase@google.com>
We replaced http.DefaultClient with securityPreservingHTTPClient,
but we still need that too many redirects check. This issue introduced
by CL 156838.
We introduce a special path to test rediret requests in the script test
framework. You can specify the number of redirects in the path.
$GOPROXY/redirect/<count>/...
Redirect request sequence details(count=8):
request: $GOPROXY/mod/redirect/8/rsc.io/quote/@v/v1.2.0.mod
redirect: $GOPROXY/mod/redirect/7/rsc.io/quote/@v/v1.2.0.mod
redirect: $GOPROXY/mod/redirect/6/rsc.io/quote/@v/v1.2.0.mod
redirect: $GOPROXY/mod/redirect/5/rsc.io/quote/@v/v1.2.0.mod
redirect: $GOPROXY/mod/redirect/4/rsc.io/quote/@v/v1.2.0.mod
redirect: $GOPROXY/mod/redirect/3/rsc.io/quote/@v/v1.2.0.mod
redirect: $GOPROXY/mod/redirect/2/rsc.io/quote/@v/v1.2.0.mod
redirect: $GOPROXY/mod/redirect/1/rsc.io/quote/@v/v1.2.0.mod
the last: $GOPROXY/mod/rsc.io/quote/@v/v1.2.0.mod
Fixes#39482
Change-Id: I149a3702b2b616069baeef787b2e4b73afc93b0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/237177
Run-TryBot: Baokun Lee <nototon@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
This API and functionality was added late in the Go 1.15 release
cycle, and use within gopls has revealed some shortcomings. It's
possible (but not decided) that we'll want a different API long-term,
so for now this CL renames UsesCgo to a non-exported name to avoid
long-term commitment under the Go 1 compat guarantee.
Updates #16623.
Updates #39072.
Change-Id: I04bc0c161a84adebe43e926df5df406bc794c3db
Reviewed-on: https://go-review.googlesource.com/c/go/+/237417
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
The scheduler assumes two special invariants that apply to tuple
selectors (Select0 and Select1 ops):
1. There is only one tuple selector of each type per generator.
2. Tuple selectors and generators reside in the same block.
Prior to this CL the assumption was that these invariants would
only be broken by the CSE pass. The CSE pass therefore contained
code to move and de-duplicate selectors to fix these invariants.
However it is also possible to write relatively basic optimization
rules that cause these invariants to be broken. For example:
(A (Select0 (B))) -> (Select1 (B))
This rule could result in the newly added selector (Select1) being
in a different block to the tuple generator (see issue #38356). It
could also result in duplicate selectors if this rule matches
multiple times for the same tuple generator (see issue #39472).
The CSE pass will 'fix' these invariants. However it will only do
so when optimizations are enabled (since disabling optimizations
disables the CSE pass).
This CL moves the CSE tuple selector fixup code into its own pass
and makes it mandatory even when optimizations are disabled. This
allows tuple selectors to be treated like normal ops for most of
the compilation pipeline until after the new pass has run, at which
point we need to be careful to maintain the invariant again.
Fixes#39472.
Change-Id: Ia3f79e09d9c65ac95f897ce37e967ee1258a080b
Reviewed-on: https://go-review.googlesource.com/c/go/+/237118
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This removes the same logic from run.bat that was removed from
cmd/dist in CL 236819.
The duplicated logic was removed from run.bash and run.rc in CL 6531,
but that part of run.bat was apparently missed (and not noticed
because its effect was redundant).
Also fix a path-separator bug in cmd/addr2line.TestAddr2Line that was
exposed as a result.
Fixes#39478
Updates #39385
Change-Id: I00054966cf92ef92a03681bf23de7f45f46fbb5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/237359
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Restore previously sent SCTs and stapled OCSP response during session
resumption for both TLS 1.2 and 1.3. This behavior is somewhat
complicated for TLS 1.2 as SCTs are sent during the server hello,
so they override what is saved in ClientSessionState. It is likely
that if the server is sending a different set of SCTs there is probably
a reason for doing so, such as a log being retired, or SCT validation
requirements changing, so it makes sense to defer to the server in
that case.
Fixes#39075
Change-Id: I3c0fa2f69c6bf0247a447c48a1b4c733a882a233
Reviewed-on: https://go-review.googlesource.com/c/go/+/234237
Reviewed-by: Filippo Valsorda <filippo@golang.org>
When the arrangement specifier is "B16", the 30-bit should be 1 rather than 0.
This CL fixes this error.
Fixes#39445
Change-Id: Ib44881cdb8b3aab855cb30f2c52a085cd73a6a2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/236638
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Also do not unset it by default in the tests for cmd/go.
GOROOT_FINAL affects the GOROOT value embedded in binaries,
such as 'cmd/cgo'. If its value changes and a build command
is performed that depends on one of those binaries, the binary
would be spuriously rebuilt.
Instead, only unset it in the specific tests that make assumptions
about the GOROOT paths embedded in specific compiled binaries.
That may cause those tests to do a little extra rebuilding when
GOROOT_FINAL is set, but that little bit of extra rebuilding
seems preferable to spuriously-stale binaries.
Fixes#39385
Change-Id: I7c87b1519bb5bcff64babf1505fd1033ffa4f4fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/236819
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
CL 236857 removed all uses of whitelist/blacklist, which is great.
But it substituted awkward phrasing using allowlist/blocklist,
especially as verbs or participles. This CL uses more standard English,
like "allow the function" or "blocked functions" instead of
"allowlist the function" or "blocklisted functions".
Change-Id: I9106a2fdbd62751c4cbda3a77181358a8a6d0f13
Reviewed-on: https://go-review.googlesource.com/c/go/+/236917
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
The removed line assumed that the script's WORK directory is not a
child of any directory containing version-control metadata.
While that assumption does hold in most cases, it does not hold when,
for example, $TMPDIR is $HOME/tmp and $HOME/.git/config exists.
A similar situation may or may not arise when using
golang.org/x/build/cmd/release. Either way, the assertion is incorrect
and was interfering with local testing for #39385.
Updates #39385Fixes#39431
Change-Id: I67813d7ce455aa9b56a6eace6eddebf48d0f7fa6
Reviewed-on: https://go-review.googlesource.com/c/go/+/236818
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
The page sweeper depends on spans being marked if any object in the
span is marked, but currently only greyobject does this.
gcmarknewobject and wbBufFlush1 also mark objects, but neither set
span marks. As a result, if there are live objects on a span, but
they're all marked via allocation or write barriers, then the span
itself won't be marked and the page reclaimer will free the span,
ultimately leading to memory corruption when the memory for those live
allocations gets reused.
Fix this by making gcmarknewobject and wbBufFlush1 also mark pages.
No test because I have no idea how to reliably (or even unreliably)
trigger this.
Fixes#39432.
Performance is a wash or very slightly worse. I benchmarked the
gcmarknewobject and wbBufFlush1 changes independently and both showed
a slight performance improvement, so I'm going to call this noise.
name old time/op new time/op delta
BiogoIgor 15.9s ± 2% 15.9s ± 2% ~ (p=0.758 n=25+25)
BiogoKrishna 15.7s ± 3% 15.7s ± 3% ~ (p=0.382 n=21+21)
BleveIndexBatch100 4.94s ± 3% 5.07s ± 4% +2.63% (p=0.000 n=25+25)
CompileTemplate 204ms ± 1% 205ms ± 1% +0.43% (p=0.000 n=21+23)
CompileUnicode 77.8ms ± 1% 78.1ms ± 1% ~ (p=0.130 n=23+23)
CompileGoTypes 731ms ± 1% 733ms ± 1% +0.30% (p=0.006 n=22+22)
CompileCompiler 3.64s ± 2% 3.65s ± 3% ~ (p=0.179 n=24+25)
CompileSSA 8.44s ± 1% 8.46s ± 1% +0.30% (p=0.003 n=22+23)
CompileFlate 132ms ± 1% 133ms ± 1% ~ (p=0.098 n=22+22)
CompileGoParser 164ms ± 1% 164ms ± 1% +0.37% (p=0.000 n=21+23)
CompileReflect 455ms ± 1% 457ms ± 2% +0.50% (p=0.002 n=20+22)
CompileTar 182ms ± 2% 182ms ± 1% ~ (p=0.382 n=22+22)
CompileXML 245ms ± 3% 245ms ± 1% ~ (p=0.070 n=21+23)
CompileStdCmd 16.5s ± 2% 16.5s ± 3% ~ (p=0.486 n=23+23)
FoglemanFauxGLRenderRotateBoat 12.9s ± 1% 13.0s ± 1% +0.97% (p=0.000 n=21+24)
FoglemanPathTraceRenderGopherIter1 18.6s ± 1% 18.7s ± 0% ~ (p=0.083 n=23+24)
GopherLuaKNucleotide 28.4s ± 1% 29.3s ± 1% +2.84% (p=0.000 n=25+25)
MarkdownRenderXHTML 252ms ± 0% 251ms ± 1% -0.50% (p=0.000 n=23+24)
Tile38WithinCircle100kmRequest 516µs ± 2% 516µs ± 2% ~ (p=0.763 n=24+25)
Tile38IntersectsCircle100kmRequest 689µs ± 2% 689µs ± 2% ~ (p=0.617 n=24+24)
Tile38KNearestLimit100Request 608µs ± 1% 606µs ± 2% -0.35% (p=0.030 n=19+22)
[Geo mean] 522ms 524ms +0.41%
https://perf.golang.org/search?q=upload:20200606.4
Change-Id: I8b331f310dbfaba0468035f207467c8403005bf5
Reviewed-on: https://go-review.googlesource.com/c/go/+/236817
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Rather than hashing the encoding of the SPKI structure, hash the
bytes of the public key itself.
Fixes#39429
Change-Id: I55a0f8f08ab1f1b5702590b47d8b9a92d1dbcc1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/236878
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Previously, if there was a non-directory file with the name vendor or
testdata in the Go source tree, it was possible for some directories
to be skipped by filepath.Walk performed in findGorootModules.
As unusual and unlikely as such non-directory files are, it's better
to ensure all directories are visited, and all modules in the GOROOT
source tree are found.
This increases confidence that tests relying on findGorootModule
will not have unexpected false negatives.
For #36851.
For #36907.
Change-Id: I468e80d8f57119e2c72d546b3fd1e23c31fd6e6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/236600
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
This is a followup to CL 96495.
It should be simpler and more robust to achieve .bat files having
CRLF line endings by treating it as a binary file, like all other
files, and checking it in with the desired CRLF line endings.
A test is used to check the entire Go tree, short of directories
starting with "." and named "testdata", for any .bat files that
have anything other than strict CRLF line endings. This will help
catch any accidental modifications to existing .bat files or check
ins of new .bat files.
Importantly, this is compatible with how Gerrit serves .tar.gz files,
making it so that CRLF line endings are preserved.
The Go project is supported on many different environments, some of
which may have limited git implementations available, or none at all.
Relying on fewer git features and special rules makes it easier to
have confidence in the exact content of all files. Additionally, Go
development started in Subversion, moved to Perforce, then Mercurial,
and now uses Git.¹ Reducing its reliance on git-specific features will
help if there will be another transition in the project's future.
There are only 5 .bat files in the entire Go source tree, so a new one
being added is a rare event, and we prefer to do things in Go instead.
We still have the option of improving the experience for developers by
adding a pre-commit converter for .bat files to the git-codereview tool.
¹ https://groups.google.com/d/msg/golang-dev/sckirqOWepg/YmyT7dWJiocJFixes#39391.
For #37791.
Change-Id: I6e202216322872f0307ac96f1b8d3f57cb901e6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/236437
Reviewed-by: Bryan C. Mills <bcmills@google.com>
There's been plenty of discussion on the usage of these terms in tech.
I'm not trying to have yet another debate. It's clear that there are
people who are hurt by them and who are made to feel unwelcome by their
use due not to technical reasons but to their historical and social
context. That's simply enough reason to replace them.
Anyway, allowlist and blocklist are more self-explanatory than whitelist
and blacklist, so this change has negative cost.
Didn't change vendored, bundled, and minified files. Nearly all changes
are tests or comments, with a couple renames in cmd/link and cmd/oldlink
which are extremely safe. This should be fine to land during the freeze
without even asking for an exception.
Change-Id: I8fc54a3c8f9cc1973b710bbb9558a9e45810b896
Reviewed-on: https://go-review.googlesource.com/c/go/+/236857
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Khosrow Moossavi <khos2ow@gmail.com>
Reviewed-by: Leigh McCulloch <leighmcc@gmail.com>
Reviewed-by: Urban Ishimwe <urbainishimwe@gmail.com>
This change makes the direct call darwin loadSystemRoots implementation
match the existing cgo implementation, which in turn _mostly_ matches
the Apple implementation. The main change here is that when
SecTrustSettingsCopyTrustSettings the error is ignored, and can either
cause a fallback to check admin trust settings, or cause the
certificate to be marked kSecTrustSettingsResultUnspecified.
As well as updating the implementation to match the cgo one, this
change also updates the documentation of how the fallbacks work and
how they match the Apple implementations. References are made to the
Apple source where appropriate. This change does not update the
existing comments in the cgo implementation, since the goal is to
delete that code once the direct call implementation is matured.
Updates #38888
Change-Id: Id0344ea9d2eede3b715f341e9cbd3c1c661b7a90
Reviewed-on: https://go-review.googlesource.com/c/go/+/233360
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
The ConnectionState's CipherSuite was not set prior
to the VerifyConnection callback in TLS 1.2 servers,
both for full handshakes and resumptions.
Change-Id: Iab91783eff84d1b42ca09c8df08e07861e18da30
Reviewed-on: https://go-review.googlesource.com/c/go/+/236558
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
There's a comment on the Syscall function that's supposed to be an
internal implementation note, but since it's not separated from the
function definition, it appears in godoc. Add a blank line to prevent
this.
Change-Id: Iba307f1cc3844689ec3c6d82c21d441852e35bca
Reviewed-on: https://go-review.googlesource.com/c/go/+/236561
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>