aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/api_test.go
AgeCommit message (Collapse)Author
2021-08-24cmd/compile/internal/types2: use TypeList in the Inferred structRobert Griesemer
This is a port of CL 343934 from go/types with the necessary adjustments to the compiler. Change-Id: I810144e6e2eb2bc8fa0d34dc206403c993cbbe7a Reviewed-on: https://go-review.googlesource.com/c/go/+/344616 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Dan Scales <danscales@google.com>
2021-08-22cmd/compile/internal/types2: enable TestSelection API testRobert Griesemer
This test was never fully ported from go/types. Implement a conversion function from syntax.Pos to string index so that the test can be enabled again. Also renamed the local variable syntax to segment to avoid confusion with the syntax package. Change-Id: I1b34e50ec138403798efb14c828545780f565507 Reviewed-on: https://go-review.googlesource.com/c/go/+/344253 Trust: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
2021-08-22cmd/compile/internal/types2: report argument type for unsafe.OffsetOfRobert Griesemer
Before parameterized types, unsafe.OffsetOf was always evaluating to a constant. With parameterized types, the result may be a run-time value, and unsafe.OffsetOf(x.f) is a call that is recorded. Also record the argument x.f. Fixes #47895. Change-Id: Ia3da25028d4865d7295ce7990c7216bffe9e7c72 Reviewed-on: https://go-review.googlesource.com/c/go/+/344252 Trust: Robert Griesemer <gri@golang.org> Trust: Dan Scales <danscales@google.com> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dan Scales <danscales@google.com>
2021-08-19cmd/compile/internal/types2: return an error from InstantiateRobert Findley
Change Instantiate to be a function (not a method) and return an error. Introduce an ArgumentError type to report information about which type argument led to an error during verification. This resolves a few concerns with the current API: - The Checker method set was previously just Files. It is somewhat odd to add an additional method for instantiation. Passing the checker as an argument seems cleaner. - pos, posList, and verify were bound together. In cases where no verification is required, the call site was somewhat cluttered. - Callers will likely want to access structured information about why type information is invalid, and also may not have access to position information. Returning an argument index solves both these problems; if callers want to associate errors with an argument position, they can do this via the resulting index. We may want to make the first argument an opaque environment rather than a Checker. Change-Id: I3bc56d205c13d832b538401a4c91d3917c041225 Reviewed-on: https://go-review.googlesource.com/c/go/+/342152 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-08-14cmd/compile/internal/types2: define Identical for instancesRob Findley
Instantiation of parameterized types may occur in other packages, so we need an intrinsic notion of type identity for instances. Add the natural definition: two instances are identical if their bases and type arguments are identical. Type unification was already considering type arguments, but has some inaccurate logic with respect to objects. This will be addressed in a follow-up CL. Change-Id: Ib2ce67c05de65eb302ee588cc40c89c60018da50 Reviewed-on: https://go-review.googlesource.com/c/go/+/341856 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-08-14cmd/compile/internal/types2: merge Instantiate and InstantiateLazyRob Findley
Instantiate and InstantiateLazy have the same signature; on first principles, if Instantiate should work for importers it should be possible to consolidate these APIs. This CL does this. In order to make it work, a typMap needs to be threaded through type expansion to prevent infinite recursion in the case that the Checker is nil. Notably, Named types now must be expanded before returning from Underlying(). This makes Underlying generally unsafe to call while type checking a package, so a helper function safeUnderlying is added to provide the previous behavior. This is probably overly conservative at most call sites, but cleanup is deferred to a later CL. Change-Id: I03cfb75bea0750862cd6eea4e3cdc875a7daa989 Reviewed-on: https://go-review.googlesource.com/c/go/+/341855 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-08-10[dev.typeparams] cmd/compile/internal/types2: parameterized functions must ↵Robert Griesemer
have a body Add the respective check and add missing bodies to tests. Use {} as body for functions that don't return a result. Use { panic(0) } as body for functions that return a result. For #47069. Change-Id: Ia5d7525c9c036baf8a955d13bff448401e08235e Reviewed-on: https://go-review.googlesource.com/c/go/+/340911 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-08-05[dev.typeparams] cmd/compile/internal/types2: remove ↵Robert Griesemer
TestIncompleteInterfaces (cleanup) TestIncompleteInterfaces is not useful anymore because interface printing always shows the syntactic type structure of an interface. Also remove the respective support code in interface printing and simplify that code. Move the newDefined and nopos support declarations unchanged into api_test.go where they are used. Updates #46167. Change-Id: I23e303bc4ae4271912ba75f201bd2b7cd4a17b3e Reviewed-on: https://go-review.googlesource.com/c/go/+/339832 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-29[dev.typeparams] cmd/compile: set type parameter indices when they are boundRobert Griesemer
This is a port of CL 336249 with adjustments due to slightly different handling of type parameter declaration in types2. The CL also contains adjustments to the compiler front-end. With this change it is not necessary to export type parameter indices. Filed issue #47451 so we don't forget. Change-Id: I2834f7be313fcb4763dff2a9058f1983ee6a81b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/338192 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-13[dev.typeparams] cmd/compile/internal/types2: replace types2.Instantiate ↵Robert Griesemer
with Checker.Instantiate Allow Checker.Instantiate to work with a nil *Checker receiver (for now). This opens the door to passing in a *Checker at all times. Also, added a verify flag to Instantiate, InstantiateLazy, and instance, to be able to control if constraint satisfaction should be checked or not. Removed types2.Instantiate. For #47103. Change-Id: Ie00ce41b3e50a0fc4341e013922e5f874276d282 Reviewed-on: https://go-review.googlesource.com/c/go/+/333569 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-07-09[dev.typeparams] cmd/compile/internal/types2: recursive substitution must ↵Robert Griesemer
terminate (bug fix) When types2.Instantiate is called externally, no *Checker is provided and substitution doesn't have access to Checker.typMap; and instantiation of recursive generic types leads to an infinite recursion in subst. There was a local subster.cache but it was only set and never used. Replaced subster.cache with subster.typMap, which is set to the global Checker.typMap if available, and set to a local map otherwise. This prevents such infinite recursions. Added a simple test. More generally, because we don't have a global type map for external instantiations, instantiating the same type twice, independently but with the same type arguments, will result in two different types. This is not correct. We need to provide some form of context for external instantiations (which means the importers). This is a separate but related issue which is not yet addressed (filed #47103). Change-Id: I541556c677db54f7396fd0c88c7467894dfcf2e7 Reviewed-on: https://go-review.googlesource.com/c/go/+/333383 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-06-05[dev.typeparams] cmd/compile: rename (types2.Inferred.)Targs to TArgsRobert Griesemer
This is consistent with Named.TArgs. This is a straight-forward port of https://golang.org/cl/321289 plus the necessary compiler noder changes. Change-Id: I50791e5abe0d7f294293bed65cebc8dde8bf8c06 Reviewed-on: https://go-review.googlesource.com/c/go/+/325010 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-03[dev.typeparams] cmd/compile/internal/types2: add Config.AllowTypeLists to ↵Robert Griesemer
control type list handling Eventually the flag should not be set anymore, but we set it in the compiler until all tests have been converted. Also, convert some more types2 tests to use the type set notation. Change-Id: I616599a3473451ab75d67272016b2bd3de6835af Reviewed-on: https://go-review.googlesource.com/c/go/+/324571 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-05-21[dev.typeparams] cmd/compile: get export/import of generic types & functions ↵Dan Scales
working The general idea is that we now export/import typeparams, typeparam lists for generic types and functions, and instantiated types (instantiations of generic types with either new typeparams or concrete types). This changes the export format -- the next CL in the stack adds the export versions and checks for it in the appropriate places. We always export/import generic function bodies, using the same code that we use for exporting/importing the bodies of inlineable functions. To avoid complicated scoping, we consider all type params as unique and give them unique names for types1. We therefore include the types2 ids (subscripts) in the export format and re-create on import. We always access the same unique types1 typeParam type for the same typeparam name. We create fully-instantiated generic types and functions in the original source package. We do an extra NeedRuntimeType() call to make sure that the correct DWARF information is written out. We call SetDupOK(true) for the functions/methods to have the linker automatically drop duplicate instantiations. Other miscellaneous details: - Export/import of typeparam bounds works for methods (but not typelists) for now, but will change with the typeset changes. - Added a new types.Instantiate function roughly analogous to the types2.Instantiate function recently added. - Always access methods info from the original/base generic type, since the methods of an instantiated type are not filled in (in types2 or types1). - New field OrigSym in types.Type to keep track of base generic type that instantiated type was based on. We use the generic type's symbol (OrigSym) as the link, rather than a Type pointer, since we haven't always created the base type yet when we want to set the link (during types2 to types1 conversion). - Added types2.AsTypeParam(), (*types2.TypeParam).SetId() - New test minimp.dir, which tests use of generic function Min across packages. Another test stringimp.dir, which also exports a generic function Stringify across packages, where the type param has a bound (Stringer) as well. New test pairimp.dir, which tests use of generic type Pair (with no methods) across packages. - New test valimp.dir, which tests use of generic type (with methods and related functions) across packages. - Modified several other tests (adder.go, settable.go, smallest.go, stringable.go, struct.go, sum.go) to export their generic functions/types to show that generic functions/types can be exported successfully (but this doesn't test import). Change-Id: Ie61ce9d54a46d368ddc7a76c41399378963bb57f Reviewed-on: https://go-review.googlesource.com/c/go/+/319930 Trust: Dan Scales <danscales@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Dan Scales <danscales@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-05-14[dev.typeparams] cmd/compile/internal/types2: use Checker-provided type ↵Robert Griesemer
parameter IDs when possible This is a port of https://golang.org/cl/317472. For #46003. Change-Id: Ie7b8880d43d459527b981ed4f60ee4d80a3cd17a Reviewed-on: https://go-review.googlesource.com/c/go/+/320149 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-04-28go/types: better errors for invalid short var declsRob Findley
This is a port of CL 312170 to go/types, adjusted to use go/ast and to add error codes. go/parser already emits errors for non-identifiers on the LHS of a short var decl, so a TODO is added to reconsider this redundancy. A new error code is added for repeated identifiers in short var decls. This is a bit specific, but I considered it to be a unique kind of error. The x/tools tests for this port turned up a bug: the new logic failed to call recordDef for blank identifiers. Patchset #2 contains the fix for this bug, both in go/types and cmd/compile/internal/types2. Change-Id: Ibdc40b8b4ad0e0696111d431682e1f1056fd5eeb Reviewed-on: https://go-review.googlesource.com/c/go/+/314629 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-04-22cmd/compile/internal/types2: avoid follow-on errors for invalid [...] arrayRobert Griesemer
Fixes #42987. Change-Id: Iaaa46e1f79525cd1e418c1a81a6414d11f8120b5 Reviewed-on: https://go-review.googlesource.com/c/go/+/311889 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-21cmd/compile: allow conversion from slice to array ptrJosh Bleecher Snyder
Panic if the slice is too short. Updates #395 Change-Id: I90f4bff2da5d8f3148ba06d2482084f32b25c29a Reviewed-on: https://go-review.googlesource.com/c/go/+/301650 Trust: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-14cmd/compile/internal/types2: use a global atomic counter for type parameter idsRobert Griesemer
This avoids a dependency on a *Checker when we create type parameters outside the type checker proper, e.g. in an importer. There may be better solutions but this does the trick for now. Change-Id: Icf22c934970cb04c88c2729555ae6a79ef5a2245 Reviewed-on: https://go-review.googlesource.com/c/go/+/309830 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-07cmd/compile/internal/types2: remove Config.AcceptMethodTypeParams flagRobert Griesemer
Type parameters for methods are not part of the accepted language, but maintaining the code for type-checking them ensures regularity of the type checker implementation. For now, keep the flag internally, disabled by default. The flag is set when running tests. Change-Id: Ic99934bd00bd2608dc1178e4131f46dd1507f0f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/307214 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-07cmd/compile/internal/types2: remove Config.InferFromConstraints flagRobert Griesemer
Constraint type inference is part of the proposed language. Use an internal flag to control the feayure for debugging. Change-Id: I7a9eaee92b5ffc23c25d9e68a729acc0d705e879 Reviewed-on: https://go-review.googlesource.com/c/go/+/306770 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-03-25cmd/compile/internal/types2: review of api_test.goRobert Griesemer
The changes between (equivalent, and reviewed) go/types/api_test.go and api_test.go can be seen by comparing patchset 1 and 2. The actual changes are removing the "// UNREVIEWED" marker, the addition of the TestConvertibleTo and TestAssignableTo tests, and adjustments to test prefixes (genericPkg, brokenPkg to be in line with go/types). There are several differences to go/types/api_test.go: - use of syntax rather than go/ast package - use of the parseSrc helper function - TestTypesInfo test entries reflect different handling of untyped nil - TestInferredInfo is (for go1.17) in another file controlled by a build constraint in go/types - TestSelection test is currently skipped (types2 position information is not accurate enough) - TestScopeLookupParent doesn't have access to a scanner and instead relies on syntax.CommentsDo. - Broken packages are assumed to contain generic code for the tests. Change-Id: Ic14e6fb9d6bef5416df39e465b5994de76f84097 Reviewed-on: https://go-review.googlesource.com/c/go/+/304131 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-03-18cmd/compile/internal/types2: delay recording types of untyped operands when ↵Robert Griesemer
checking against type parameters Don't eagerly record the target type for an untyped operand if the target type is just one of possibly many types in the type list of a type parameter. Instead, record expression type only after we checked that all types in the type list are ok. Also, update assertion in Checker.recordTypeAndValue since (currently), a type parameter is not considered a const type. We may change that, eventually. This is a temporary (but working) solution. Eventually we should copy the approach taken in go/types. Fixes #45096. Change-Id: Icf61ee893aca6ead32bfc45ee5831572e672357b Reviewed-on: https://go-review.googlesource.com/c/go/+/302755 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-01-21[dev.typeparams] cmd/compile/internal/types2: make predeclared "any" alias ↵Robert Griesemer
for interface{} If we ever decide to permit the use of the predeclared identifier "any" in lieu of interface{}, it must be an alias for interface{}. Change-Id: Ic751d7f9b61133fb57625f56ce95d99f034b32c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/285132 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-01-20[dev.typeparams] cmd/compile/internal/types2: report type of nil based on ↵Robert Griesemer
context With this CL, the type reported for uses of the predeclared identifier nil changes from untyped nil to the type of the context within which nil is used, matching the behaviour of types2 for other untyped types. If an untyped nil value is assigned or converted to an interface, the nil expression is given the interface type. The predicate TypeAndValue.IsNil doesn't change in behavior, it still reports whether the relevant expression is a (typed or untyped) nil value. Change-Id: Id766468f3f3f2a53e4c55e1e6cd521e459c4a94f Reviewed-on: https://go-review.googlesource.com/c/go/+/284218 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-15[dev.typeparams] cmd/compile/internal/types2: consistently report nil type ↵Robert Griesemer
as "untyped nil" This fixes an inconsistency where the type for nil in code such as var x unsafe.Pointer = nil and in conversions of the form T(nil) (where T is a pointer, function, slice, map, channel, interface, or unsafe.Pointer) was reported as (converted to) the respective type. For all other operations that accept a nil value, we don't do this conversion for nil. (We never change the type of the untyped nil value, in contrast to other untyped values where we give the values context-specific types.) It may still be useful to change this behavior and - consistently - report a converted nil type like we do for any other type, but for now this CL simply fixes the existing inconsistency. Added tests and fixed existing test harness. Updates #13061. Change-Id: Ia82832845c096e3cbc4a239ba3d6c8b9a9d274c9 Reviewed-on: https://go-review.googlesource.com/c/go/+/284052 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-01-11[dev.typeparams] cmd/compile/internal/types2: fixes for all.bashMatthew Dempsky
This CL implements a number of minor fixes that were discovered in getting -G=3 working for running all.bash. 1. Field tags were handled incorrectly. If a struct type had some fields with tags, but later fields without tags, the trailing tag-less fields would all copy the tag of the last tagged field. Fixed by simply reinitializing `tag` to "" for each field visited. 2. Change the ending of switch case clause scopes from the end of the last statement to the next "case" token or the switch-ending "}" token. I don't think this is strictly necessary, but it matches my intuition about where case-clause scopes end and cmd/compile's current scoping logic (admittedly influenced by the former). 3. Change select statements to correctly use the scope of each individual communication clause, instead of the scope of the entire select statement. This issue appears to be due to the original go/types code being written to rebind "s" from the *SelectStmt to the Stmt in the range loop, and then being further asserted to "clause" of type *CommClause. In most places within the loop body, "clause" was used, but the rebound "s" identifier was used for the scope boundaries. However, in the syntax AST, SelectStmt directly contains a []*CommClause (rather than a *BlockStmt, with []Stmt), so no assertion is necessary and instead of rebinding "s", the range loop was updated to directly declare "clause". 4. The end position for increment/decrement statements (x++/x--) was incorrectly calculated. Within the syntax AST, these are represented as "x += ImplicitOne", and for AssignStmts types2 calculated the end position as the end position of the RHS operand. But ImplicitOne doesn't have any position information. To workaround this, this CL detects ImplicitOne and then computes the end position of the LHS operand instead, and then adds 2. In practice this should be correct, though it could be wrong for ill-formatted statements like "x ++". Change-Id: I13d4830af39cb3f3b9f0d996672869d3db047ed2 Reviewed-on: https://go-review.googlesource.com/c/go/+/282914 Trust: Matthew Dempsky <mdempsky@google.com> Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-01-08[dev.typeparams] cmd/compile/internal/syntax: remove ShortString, use String ↵Robert Griesemer
instead Follow-up on feedback by mdempsky@ in https://golang.org/cl/282552 . Change-Id: I1e5bb2d67cc8ae29fed100b87d18a33b3e2069eb Reviewed-on: https://go-review.googlesource.com/c/go/+/282672 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-08[dev.typeparams] cmd/compile/internal/types2: use syntax printer to print ↵Robert Griesemer
expressions The syntax package has a full-fledged node printer. Use that printer to create the expression strings needed in error messages, and remove the local (essentially) duplicate code for creating expression strings. Change-Id: I03673e5e79b3c1470f8073ebbe840a90fd9053ec Reviewed-on: https://go-review.googlesource.com/c/go/+/282553 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-27[dev.typeparams] cmd/compile: re-enable internal/types2 testRuss Cox
CL 279531 disabled these because they were causing trouble with the automation for the big move. The big move is over. Reenable them. Change-Id: I2b06f619a114ebcc9b9af73ce0d5b68ebaeaac03 Reviewed-on: https://go-review.googlesource.com/c/go/+/279993 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-23[dev.typeparams] cmd/compile/internal/types2: disable external test temporarilyRuss Cox
This is making rf unhappy for extremely subtle reasons, so for now just disable the external test here. Will reenable once the big rewrite is done. Change-Id: Ifd1ba95e2843792427629d1660850fe531cdd0b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/279531 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2020-12-01[dev.typeparams] cmd/compile/internal/types2: adjustments toward matching ↵Robert Griesemer
compiler error messages In order to get types2 usable by the compiler, we need to pass all the compiler tests with respect to error messages. Sometimes the compiler error messages are better, sometimes the types2 error messages are better. Where we can, we decide on a case-by-case basis; but sometimes, for expediency's sake, we just choose the compiler error message as it may reduce the amount of tests that we need to update. This CL introduces a new Config flag: CompilerErrorMessages. If set, the typechecker emits an error message that matches the expected errors in the tests most easily. Eventually, we need to get rid of this flag by either adjusting the typechecker errors or the test cases; t.b.d. on a case-by-case basis. This CL also adjust a few error typechecker error messages already. Change-Id: I9d4e491efadf87e999fc0d5b5151ec02a059f891 Reviewed-on: https://go-review.googlesource.com/c/go/+/274312 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-10-21[dev.typeparams] cmd/compile/internal/importer, types2: initial check-in of ↵Robert Griesemer
types2 and importer This is a copy of the importer and types2 (unreviewed) prototype version excluding the testdata directory containing tests (see below). Each file is marked with the comment // UNREVIEWED on the first line. The plan is to check in this code wholesale (it runs and passes all tests) and then review the code file-by-file via subsequent CLs and remove the "// UNREVIEWED" comments as we review the files. Since most tests are unchanged from the original go/types, the next CL will commit those tests as they don't need to be reviewed again. (Eventually we may want to factor them out and share them from a single place, e.g. the test directory.) The existing file fmtmap_test.go was updated. Change-Id: I9bd0ad1a7e7188b501423483a44d18e623c0fe71 Reviewed-on: https://go-review.googlesource.com/c/go/+/263624 Trust: Robert Griesemer <gri@golang.org> Trust: Keith Randall <khr@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>