aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/testdata
AgeCommit message (Collapse)Author
2021-08-26cmd/compile/internal/types2: address some TODOs (cleanup)Robert Griesemer
- Address some easy TODOs. - Remove some TODOs that are not correct anymore or are unimportent. - Simplify some code on the way. Change-Id: I4d20de3725b3a735022afe022cbc002b2798936d Reviewed-on: https://go-review.googlesource.com/c/go/+/345176 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-08-25cmd/compile: always accept 1.18 syntax but complain if not 1.18Robert Griesemer
This CL configures the parser to always accept 1.18 syntax (type parameters, type instantiations, interface elements), even when -lang is set to an earlier release. Instead, the type checker looks for 1.18 operations and complains if the language version is set to an earlier release. Doing these checks during type checking is necessary because it it is possible to write "generic" code using pre-1.18 syntax; for instance, an imported generic function may be implicitly instantiated (as in imported.Max(2, 3)), or an imported constraint interface may be embedded in an "ordinary" interface. Fixes #47818. Change-Id: I83ec302b3f4ba7196c0a4743c03670cfb901310d Reviewed-on: https://go-review.googlesource.com/c/go/+/344871 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-08-17cmd/compile/internal/types2: fix method lookup for type-parameter based typesRobert Griesemer
Pointers to type parameters don't have methods, but pointers to defined types whose underlying types are type parameters may have methods. Fix the respective test. For #47747. Change-Id: I1de47be094ed9297f0e7782538011657c37c5adc Reviewed-on: https://go-review.googlesource.com/c/go/+/342990 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-08-17cmd/compile/internal/types2: allow composite literals of type parameter typeRobert Griesemer
Change-Id: Iaaa2a3b462da6b121f13a10595950a8502b5f271 Reviewed-on: https://go-review.googlesource.com/c/go/+/342690 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
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-06[dev.typeparams] cmd/compile/internal/types2: limit termlist lengthsRobert Griesemer
At the moment, operations on termlists are O(n^2). This is fine for normal-sized unions, but overlong termlist lenghts will lead to excessive type checking times. Limit the length of termlists to avoid "compilations that don't finish". Change-Id: I39a7fc61b01c9db06faeb49a0e014b1ede532710 Reviewed-on: https://go-review.googlesource.com/c/go/+/340254 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-08-06[dev.typeparams] cmd/compile/internal/types2: fix make with type parameter ↵Robert Griesemer
argument For make with a type parameter argument, the structural type of the type parameter's constraint determines what make is making. Change-Id: I3b48f8ce3236b7624e0638b5f5be208c5915c987 Reviewed-on: https://go-review.googlesource.com/c/go/+/339899 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-08-06[dev.typeparams] cmd/compile/internal/types2: fix range over exprs of type ↵Robert Griesemer
parameter type For range expressions of type parameter type, the structural type of the type parameter's constraint determines the range operation. While at it, rename implicitArrayDeref to arrayPtrDeref. Change-Id: Ib631a8a14e717498e5264944f659309df1f68cc2 Reviewed-on: https://go-review.googlesource.com/c/go/+/339897 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-08-05[dev.typeparams] cmd/compile/internal/types2: implement type sets with term ↵Robert Griesemer
lists This CL resolves several known issues and TODOs. - Represent type sets with term lists and using term list abstractions. - Represent Unions internally as a list of (syntactical) terms. Use term operations to print terms and detect overlapping union entries. - Compute type sets corresponding to unions lazily, on demand. - Adjust code throughout. - Adjusted error check in test/typeparam/mincheck.dir/main.go to make test pass. Change-Id: Ib36fb7e1d343c2b6aec51d304f0f7d1ad415f999 Reviewed-on: https://go-review.googlesource.com/c/go/+/338310 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-29[dev.typeparams] cmd/compile/internal/types2: trigger verification while ↵Robert Griesemer
resolving instance This is a straight port of CL 335978 with minor adjustements to white space and an error message. Change-Id: Icfcb562f75802a119ce5d02427bffecf7e279b2f Reviewed-on: https://go-review.googlesource.com/c/go/+/338097 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-29[dev.typeparams] cmd/compile/internal/types2: use type terms to represent unionsRobert Griesemer
This is just an internal representation change for now. Change-Id: I7e0126e9b17850ec020c2a60db13582761557bea Reviewed-on: https://go-review.googlesource.com/c/go/+/338092 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-28[dev.typeparams] cmd/compile/internal/types2: merge instance and Named to ↵Rob Findley
eliminate sanitization This is a port of CL 335929 to types2. It differs significantly from that CL to handle lazy loading, which wasn't tested in go/types. Additionally, the *Checker field was moved out of instance and back onto Named. This way we can tell whether a Named type is uninstantiated simply by checking whether Named.instance is non-nil, which simplified the code considerably. Fixes #46151 Change-Id: I617263bcfaa768ac5442213cecad8d567c2749fc Reviewed-on: https://go-review.googlesource.com/c/go/+/336252 Trust: Robert Findley <rfindley@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-07-27[dev.typeparams] cmd/compile/internal/types2: use comparable bit rather than ↵Robert Griesemer
==() method This removes the special "==" methods from comparable interfaces in favor of a "comparable" flag in TypeSets indicating that the interface is or embeds comparable. Fixes various related implementation inaccuracies. While at it, fix setup of the predeclared error and comparable interface types by associating their respective type name objects with them. For #47411. Change-Id: I409f880c8c8f2fe345621401267e4aaabd17124d Reviewed-on: https://go-review.googlesource.com/c/go/+/337354 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-26[dev.typeparams] cmd/compile/internal/types2: embedded type cannot be a ↵Robert Griesemer
(pointer to) a type parameter Change-Id: I5eb03ae349925f0799dd866e207221429bc9fb3c Reviewed-on: https://go-review.googlesource.com/c/go/+/337353 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-26[dev.typeparams] cmd/compile/internal/types2: import regexp/syntax instead ↵Robert Griesemer
of cmd/compile/internal/syntax This is a straight port of https://golang.org/cl/330431. For #43232 Change-Id: I5954bdff22a524eaa08754947da9b428b27f7d95 Reviewed-on: https://go-review.googlesource.com/c/go/+/336351 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-26[dev.typeparams] cmd/compile/internal/types2: fix a bug in package ↵Robert Griesemer
qualification logic This is a partial port of https://golang.org/cl/330629, containing only the actual bug fix and adjustements to another test file. The respective test case has not been ported yet as it requires some bigger adjustments. For #46905 Change-Id: Ibd20658b8a31855da20cf56e24bcce9560656ca0 Reviewed-on: https://go-review.googlesource.com/c/go/+/336350 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-07-22[dev.typeparams] cmd/compile/internal/types2: adjust ↵Robert Griesemer
unsafe.Alignof/Offsetof/Sizeof Changed the implementation such that the result is a variable rather than a constant if the argument type (or the struct in case of unsafe.Offsetof) has a size that depends on type parameters. Minor unrelated adjustments. For #40301. Change-Id: I1e988f1479b95648ad95a455c764ead829d75749 Reviewed-on: https://go-review.googlesource.com/c/go/+/335413 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-16[dev.typeparams] cmd/compile/internal/types2: more consistent handling of ↵Robert Griesemer
predeclared "any" Rather than removing "any" from the universe scope, keep it predeclared but provide a better error message. While at it, remove some unnecessary type assertions. Change-Id: I10603274282ea6afc107f703ab194f32bd334dd1 Reviewed-on: https://go-review.googlesource.com/c/go/+/334911 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14[dev.typeparams] cmd/compile/internal/types2: embedding stand-alone type ↵Robert Griesemer
parameters is not permitted For #47127. Change-Id: Ie979ff56ae7c2dd0e5ce0ff39588f98ae68b5ee9 Reviewed-on: https://go-review.googlesource.com/c/go/+/334151 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14[dev.typeparams] cmd/compile/internal/types2: fix generic type indirectionRobert Griesemer
Change-Id: If25ceb2aa403b94608760be331faa2aff11c47cc Reviewed-on: https://go-review.googlesource.com/c/go/+/333890 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14[dev.typeparams] cmd/compile/internal/types2: cleanups around receiver type ↵Robert Griesemer
checks Generic receiver types may be defined such that an instantiated receiver ends up being a pointer type. Disallow them as we do for non-generic receivers. Change-Id: I6612a52615a2999375c35aa1d69ab42f37d9f55d Reviewed-on: https://go-review.googlesource.com/c/go/+/333770 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14[dev.typeparams] cmd/compile/internal/types2: implement delete(m, k) where m ↵Robert Griesemer
is of type parameter type Change-Id: Iaf33c15128af911b6101df9885cb8b5a8495b942 Reviewed-on: https://go-review.googlesource.com/c/go/+/333729 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14[dev.typeparams] cmd/compile/internal/types2: implement close(ch) where ch ↵Robert Griesemer
is of type parameter type Change-Id: I45189468553e83390fd2640b5708c60a7852fbb5 Reviewed-on: https://go-review.googlesource.com/c/go/+/333713 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14[dev.typeparams] cmd/compile/internal/types2: implement ch <- x where ch is ↵Robert Griesemer
of type parameter type For #47115. Change-Id: Ib9c8652c0346029369735ccf7ee9098ab1ae7fd3 Reviewed-on: https://go-review.googlesource.com/c/go/+/333712 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-14[dev.typeparams] cmd/compile/internal/types2: implement <-ch where ch is of ↵Robert Griesemer
type parameter type For #43671 Change-Id: I7db4b3886fab44ec0de7c0935e0ab21c26e3335c Reviewed-on: https://go-review.googlesource.com/c/go/+/333709 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-07[dev.typeparams] cmd/compile/internal/types2: don't permit method calls on ↵Robert Griesemer
ptr to type parameter receivers Simplify the implementation of asInterface while at it. For #47031. Change-Id: Ie7d4fbbab898d961ed3c0b7772ba9604641be13f Reviewed-on: https://go-review.googlesource.com/c/go/+/332609 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-07[dev.typeparams] cmd/compile/internal/types2: replace optype() with under() ↵Robert Griesemer
in various cases (cleanup) This makes the behavior for type parameter operands explicit in those cases. Change-Id: I38438af67de4432f1a691dc4947e4576445f031b Reviewed-on: https://go-review.googlesource.com/c/go/+/332555 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-07[dev.typeparams] cmd/compile/internal/types2: clean up index expr ↵Robert Griesemer
implementation for type parameters This makes the implementation match the intended spec behavior: Given an index expression a[x] where a is a type parameter, the index expression is valid if the constraint for a satisfies the following criteria: - Either all types in the constraint type set are maps, or none of them are. - If the (type set) types are maps, they must all have the same key type. (This may be too strict, perhaps it's sufficient to ensure assignability, but we can always relax that later.) - All (type set) types must have the same element types. - If there are any arrays, a constant index must be in range for the shortest array. Change-Id: I8c094c11e6fc9496c293871ccf93e3814c881e6f Reviewed-on: https://go-review.googlesource.com/c/go/+/332553 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-07[dev.typeparams] cmd/compile/internal/types2: disallow "free" type parameter ↵Robert Griesemer
as RHS of a type declaration For #45639. Change-Id: I20e331b04f464db81e916af75f70ec8ae73eb989 Reviewed-on: https://go-review.googlesource.com/c/go/+/332411 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-01[dev.typeparams] cmd/compile/internal/types2: delay interface check for type ↵Robert Griesemer
bounds While at it, clean up code for collecting/declaring type parameters. For #40789. Change-Id: I0855137d5ee85c0ae2fa60d33b28c24a33132fbc Reviewed-on: https://go-review.googlesource.com/c/go/+/331690 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-07-01[dev.typeparams] cmd/compile/internal/types2: "comparable" must not be ↵Robert Griesemer
visible before Go 1.18 While at it, clean up the setup of comparable in universe.go. Fixes #46090 Change-Id: I9655b3e137a03763d677d9a2a730c5570ccff6dc Reviewed-on: https://go-review.googlesource.com/c/go/+/331517 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-30[dev.typeparams] cmd/compile/internal/types2: introduce type set abstraction ↵Robert Griesemer
for interfaces With this change, interfaces are "completed" on-demand, when needed, and the respective information (set of all methods, type constraints) is recorded in a new typeSet data structure. As a consequence, interfaces don't need to be explicitly completed anymore and (internal) uses of interfaces have become much simpler. This change also introduces a new field Interface.complete to indicate that all methods and embedded elements have been set up. This prevent the computation and recording (!) of a partial type set for erroneous programs (if we compute the partial type set and store it, subsequent type set accesses use the wrong type set which may lead to follow-on errors). Change-Id: I1ffc907f7d0fb93b3e987fe5ff9c6fa5cae00d7f Reviewed-on: https://go-review.googlesource.com/c/go/+/329309 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-17[dev.typeparams] cmd/compile: make types2 report better error for invalid ↵Cuong Manh Le
untyped operation This ports the fix in CL 328050 for typecheck to types2. The fix is not identical, due to code structure differences between typecheck and types2, but the idea is the same. We only do the untyped conversion when both operands can be mixed. Updates #46749 Change-Id: Ib2c63ba0d5dd8bf02318b1bfdfe51dcaeeeb7f82 Reviewed-on: https://go-review.googlesource.com/c/go/+/328053 Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-08[dev.typeparams] cmd/compile/internal/types2: provide valid signature in ↵Robert Griesemer
errors involving method expressions This is an adjusted port of a similar fix in https://golang.org/cl/324733. Fixes #46583. Change-Id: Ica1410e4de561e64e58b753e3da04b32156cbaf6 Reviewed-on: https://go-review.googlesource.com/c/go/+/325369 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-06-03[dev.typeparams] cmd/compile/internal/types2: disallow ~T where T is a ↵Robert Griesemer
defined type or an interface Change-Id: I35f6f43db00d56847da48320308f2fcfff924738 Reviewed-on: https://go-review.googlesource.com/c/go/+/324570 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-02[dev.typeparams] cmd/compile/internal/types2: convert testdata/check tests ↵Robert Griesemer
to type set sytax Change-Id: I0c2dda10ba7cb40330545fd10fbacb8c84f66a2d Reviewed-on: https://go-review.googlesource.com/c/go/+/324569 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-02[dev.typeparams] cmd/compile/internal/types2: convert testdata/fixedbugs ↵Robert Griesemer
tests to type set sytax Change-Id: I2ad94c71bebb93e0e3f4eba9d5199a3b3e9fa63d Reviewed-on: https://go-review.googlesource.com/c/go/+/324530 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-02[dev.typeparams] cmd/compile/internal/types2: convert testdata/examples ↵Robert Griesemer
tests to type set sytax Change-Id: Ida3837c9cbb970a2b49cd1598c6e6e9de8aa9690 Reviewed-on: https://go-review.googlesource.com/c/go/+/324529 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-06-02[dev.typeparams] cmd/compile/internal/types2: clean up type set/union ↵Robert Griesemer
intersection - Eliminate the need for bottom type: This is now represented by an empty union (denoting the set of no types). - Clean up type set intersection and incorporate tilde information in intersection operation and satisfaction tests. - Minor cleanups along the way. - Note: The intersection algorithm does not always compute the largest possible intersection. To be addressed in a follow-up CL. Change-Id: I7fa19df5996da36a4d8f29300d30a0aa4d8a3e5c Reviewed-on: https://go-review.googlesource.com/c/go/+/323354 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-05-24[dev.typeparams] cmd/compile/internal/types2: accept embedded interface elementsRobert Griesemer
Accept embedded interface elements of the form ~T or A|B and treat them like type lists: for now the elements of a union cannot be interfaces. Also, translate existing style "type"- lists in interfaces into interface elements: "type a, b, c" becomes a union element "~a|~b|~c" which in turn is handled internally like a type list. For now, "~" is still ignored and type lists are mapped to Sum types as before, thus ensuring that all existing tests work as before (with some minor adjustments). Introduced a new Union type to represent union elements. For now they don't make it past interface completion where they are represented as a Sum type. Thus, except for printing (and the respective tests) and substitution for interfaces, the various type switches ignore Union types. In a next step, we'll replace Sum types with union types and then consider the ~ functionality as well. Because union elements are no different from embedded interfaces we don't need a separate Interface.types field anymore. Removed. For #45346. Change-Id: I98ac3286aea9d706e98aee80241d4712ed99af08 Reviewed-on: https://go-review.googlesource.com/c/go/+/321689 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-05-19[dev.typeparams] cmd/compile/internal/types2: use correct type parameter ↵Robert Griesemer
list in missingMethod For #46275 Change-Id: Iaed9d8ba034ad793e5c57f2be174f01a535fee95 Reviewed-on: https://go-review.googlesource.com/c/go/+/321232 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-05-19[dev.typeparams] cmd/compile/internal/types2: better recv Var for method ↵Matthew Dempsky
expressions When synthesizing the Signature to represent a method expression, keep as much of the original parameter as possible, substituting only the receiver type. Fixes #46209. Change-Id: Ic4531820ae7d203bb0ba25a985f72d219b4aa25f Reviewed-on: https://go-review.googlesource.com/c/go/+/320489 Trust: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
2021-05-07cmd/compile/internal/types2: add test case for issue 45985Robert Griesemer
This is a port of https://golang.org/cl/317471. Updates #45985. Change-Id: I539d0fa6f9a77eb2fc169a21c5db9921f8eceb03 Reviewed-on: https://go-review.googlesource.com/c/go/+/317732 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-05-05cmd/compile/internal/types2: make TestManual work for directoriesRobert Griesemer
If no source argument is provided, test testdata/manual.go2 instead. Remove testdata/check/tmp/go2 in favor of testdata/manual.go2. These changes affect testing only. Change-Id: I49aba4d8fc4cc5964911e38c55b4c5d013710aeb Reviewed-on: https://go-review.googlesource.com/c/go/+/315769 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-30math: increase precision of math.SmallestNonzeroFloat64Robert Griesemer
The original value was rounded too early, which lead to the surprising behavior that float64(math.SmallestNonzeroFloat64 / 2) wasn't 0. That is, the exact compile-time computation of math.SmallestNonzeroFloat64 / 2 resulted in a value that was rounded up when converting to float64. To address this, added 3 more digits to the mantissa, ending in a 0. While at it, also slightly increased the precision of MaxFloat64 to end in a 0. Computed exact values via https://play.golang.org/p/yt4KTpIx_wP. Added a test to verify expected behavior. In contrast to the other (irrational) constants, expanding these extreme values to more digits is unlikely to be important as they are not going to appear in numeric computations except for tests verifying their correctness (as is the case here). Re-enabled a disabled test in go/types and types2. Updates #44057. Fixes #44058. Change-Id: I8f363155e02331354e929beabe993c8d8de75646 Reviewed-on: https://go-review.googlesource.com/c/go/+/315170 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-04-29cmd/compile/internal/types2: slice-to-array-pointer conversion requires go1.17Robert Griesemer
Add missing version check. Even though this is a new types2 error we separate between the compiler and the types2 error message: we have the compiler error message to match the compiler style, and we have a types2-specific error message to match the types2 style for these kinds of errors (for now). Eventually we need to decide which style we like better and clean this up. Follow-up on https://golang.org/cl/301650. Updates #395. Change-Id: I5b779f345994c66b1f4a4db466466f98b7d3c491 Reviewed-on: https://go-review.googlesource.com/c/go/+/315169 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-29cmd/compile/internal/types2: nest all test data under the testdata directoryRobert Griesemer
This matches https://golang.org/cl/314829 for go/types. Change-Id: If3d127af0557bb13d504581920ea03e39db0eb07 Reviewed-on: https://go-review.googlesource.com/c/go/+/314772 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-28cmd/compile/internal/types2: catch unexpected expression listsRobert Griesemer
This is a modified port of the https://golang.org/cl/313909 change for go/types. - add catch-all cases for unexpected expression lists - add Checker.singleIndex function to check single indices - better syntax error handling in parser for invalid type instantiations that are missing a type argument Change-Id: I6f0f396d637ad66b79f803d886fdc20ee55a98b3 Reviewed-on: https://go-review.googlesource.com/c/go/+/314409 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-23cmd/compile/internal/types2: add unsafe.Add and unsafe.SliceMatthew Dempsky
This is a port of CL 312212, CL 312591 (except check_test.go), and CL 312790 to types2. Updates #19367. Updates #40481. Change-Id: I58ba0b0dad157baba3f82c909d5eb1268b931be4 Reviewed-on: https://go-review.googlesource.com/c/go/+/312511 Trust: Matthew Dempsky <mdempsky@google.com> Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>