aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/expr.go
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-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-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: expand is only required for ↵Robert Griesemer
*Named types Now that the pointer identity for a *Named type doesn't change anymore when going from lazy instantiated to actually instantiated (= expanded) state, expand() only needs to be called when we deal with *Named types and only if we care about a *Named type's internals. Remove the expand function and respective calls for all types and replace with specific t.expand() method calls where t is a *Named. Change-Id: If82299360d60108b00adc4013b29399aec90b940 Reviewed-on: https://go-review.googlesource.com/c/go/+/340749 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@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: 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: 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-06-30[dev.typeparams] cmd/compile/internal/types2: remove unused *Checker ↵Robert Griesemer
arguments (cleanup) Simplified names and unnecessary function indirections where possible. Change-Id: I1c7a386393d086fd7ad29f892e03f048781f3547 Reviewed-on: https://go-review.googlesource.com/c/go/+/331512 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: 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-02[dev.typeparams] cmd/compile/internal/types2: replace Sum type with Union typeRobert Griesemer
- We still mostly ignore the tilde information. - More consistent naming: A Union term is the pair (type, tilde). Rename Union.terms to Union.types; the Union.types and Union.tilde slices make up the Union terms. - Replace Sum.is with Union.underIs: underIs iterates through all union terms and calls its argument function with the underlying type of the term (and thus can ignore the tilde information). This also eliminates the need to call under in the argument function. - Added Union.is for situations where we need to consider the tilde information for each Union term. Change-Id: I70fcf1813e072651dc0f61d52d5555642ee762fd Reviewed-on: https://go-review.googlesource.com/c/go/+/323274 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-26cmd/compile/internal/types2: respect IgnoreFuncBodies for function literalsRobert Griesemer
Updates #45783. Change-Id: Id552a60f262e2da62125acd6aec0901a82f5a29a Reviewed-on: https://go-review.googlesource.com/c/go/+/313650 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-04-10cmd/compile/internal/types2: split out function instantiation from index exprRobert Griesemer
Also, factor out recording of type/value information after evaluating an expression into an operand, so that we can use it when handling instantiation expressions manually. Change-Id: I6776e6cc243558079d6a203f2fe0a6ae0ecc33de Reviewed-on: https://go-review.googlesource.com/c/go/+/308371 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-10cmd/compile/internal/types2: factor out index/slice expr handlingRobert Griesemer
First step towards lightening the load of Checker.exprInternal by factoring out the code for index and slice expressions; incl. moving a couple of related methods (Checker.index, Checker.indexedElts). The code for handling index/slice expressions is copied 1:1 but occurrences of "goto Error" are replaced by "x.mode = invalid" followed by a "return". Change-Id: I44048dcc4851dc5e24f5f169c17f536a37a6a676 Reviewed-on: https://go-review.googlesource.com/c/go/+/308370 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-06cmd/compile/internal/types2: simplify Checker.CallRobert Griesemer
Now that we use square brackets for instantiations, we can tell type arguments from ordinary arguments without "guessing" which permits a simpler implementation. Specifically, replace use of Checker.exprOrTypeList with Checker.exprList, and delete Checker.exprOrTypeList and Checker.multiExprOrType. Disable a test for an (esoteric) failure due to an unrelated problem with error matching when running the test. Change-Id: I17f18fffc32f03fa90d93a68ebf56e5f2fcc9dab Reviewed-on: https://go-review.googlesource.com/c/go/+/306171 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-04-06cmd/compile/internal/types2: review of pos.go and move into syntax packageRobert Griesemer
This moves the two helper functions startPos and endPos into the syntax package where they belong. Export the functions and adjust dependent code. Change-Id: I8170faeadd7cfa8f53009f81fcffd50ec0fc6a98 Reviewed-on: https://go-review.googlesource.com/c/go/+/305578 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-03-29cmd/compile/internal/types2: remove 'strict' argument from several methodsRobert Griesemer
The value is always 'false'. Brings the code closer in line with go/types. Follow-up on https://golang.org/cl/304129. Change-Id: I8bea550033f3187b44e9a54258e0cf642c11c369 Reviewed-on: https://go-review.googlesource.com/c/go/+/304849 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-03-25cmd/compile/internal/types2: review of expr.goRobert Griesemer
The changes between (equivalent, and reviewed) go/types/expr.go and expr.go can be seen by comparing patchset 1 and 2. The actual changes are removing the "// UNREVIEWED" marker. The primary differences to go/types/expr.go are: - use of package syntax rather than ast - no reporting of error codes in errors - implicit conversions of untyped nil lead to a typed nil (in go/types, nil remains untyped) Change-Id: I1e235b20ebda597eb7ce597d1749f26431addde2 Reviewed-on: https://go-review.googlesource.com/c/go/+/303092 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-03-23cmd/compile/internal/types2: refactor untyped conversionsRobert Griesemer
Based on https://golang.org/cl/284256 for go/types. Brings this code more in line with go/types. Adjusted various tests to match new error messages which generally are now better: for assignment errors, instead of a generic "cannot convert" we now say "cannot use" followed by a clearer reason as to why not. Major differences to go/types with respect to the changed files: - Some of the new code now returns error codes, but they are only used internally for now, and not reported with errors. - go/types does not "convert" untyped nil values to target types, but here we do. This is unchanged from how types2 handled this before this CL. Change-Id: If45336d7ee679ece100f6d9d9f291a6ea55004d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/302757 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-03-13cmd/compile/internal/types2: simplify error reporting API (cleanup)Robert Griesemer
- Remove specialized errorf functions for invalid AST/argument/operation. Instead use prefix constants with the error message. - Replace several calls to Checker.errorf with calls to Checker.error if there are no arguments to format. - Replace a handful of %s format verbs with %v to satisfy vet check. - Add a basic test that checks that we're not using Checker.errorf when we should be using Checker.error. Change-Id: I7bc7c14f3cf774689ec8cd5782ea31b6e30dbcd6 Reviewed-on: https://go-review.googlesource.com/c/go/+/300995 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-02-19[dev.typeparams] cmd/compile/internal/types2: resolve decl cycle the same ↵Robert Griesemer
way as in go/types Minor adjustment to match go/types more closely. Change-Id: Id79c51f0ecd8cda0f5b68f6e961500f7f22f7115 Reviewed-on: https://go-review.googlesource.com/c/go/+/294270 Reviewed-by: Robert Findley <rfindley@google.com> Trust: Robert Griesemer <gri@golang.org>
2021-02-18[dev.typeparams] cmd/compile/internal/types2: remove Type.Under method in ↵Robert Griesemer
favor of function This removes the need for the aType embedded type and brings the types2.Type API in sync with the go/types.Type API. For reasons not fully understood yet, introducing the new under function causes a very long initialization cycle error, which doesn't exist in go/types. For now, circumvent the problem through a helper function variable. This CL also eliminates superflous (former) Under() method calls inside optype calls (optype takes care of this). Plus some minor misc. cleanups and comment adjustments. Change-Id: I86e13ccf6f0b34d7496240ace61a1c84856b6033 Reviewed-on: https://go-review.googlesource.com/c/go/+/293470 Reviewed-by: Robert Findley <rfindley@google.com> Trust: Robert Griesemer <gri@golang.org>
2021-02-18[dev.typeparams] cmd/compile/internal/types2: replace Named, TypeParam ↵Robert Griesemer
methods with functions This removes two more converter methods in favor of functions. This further reduces the API surface of types2.Type and matches the approach taken in go/types. Change-Id: I3cdd54c5e0d1e7664a69f3697fc081a66315b969 Reviewed-on: https://go-review.googlesource.com/c/go/+/293292 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-02-18[dev.typeparams] cmd/compile/internal/types2: use converter functions rather ↵Robert Griesemer
than methods This change replaces methods with functions to reduce the API surface of types2.Type and to match the approach taken in go/types. The converter methods for Named and TypeParam will be addressed in a follow-up CL. Also: Fixed behavior of optype to return the underlying type for arguments that are not type parameters. Change-Id: Ia369c796754bc33bbaf0c9c8478badecb729279b Reviewed-on: https://go-review.googlesource.com/c/go/+/293291 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-02-04[dev.typeparams] cmd/compile/internal/types2: add support for language ↵Robert Griesemer
version checking Add the Config.Lang field which may be set to a Go version string, such as "go1.12". This is a string rather than explicit semantic version numbers (such as {1, 12}) for API robustness; a string is more flexible should we need more or different information. Add -lang flag to types2 package for use with (manual) testing when running "go test -run Check$ -lang=... -files=...". While changing flags, look for comma-separated (rather than space- separated) files when providing the -file flag. Check that numeric constant literals, signed shift counts are accepted according to the selected language version. Type alias declarations and overlapping embedded interfaces are not yet checked. Updates #31793. Change-Id: I9ff238ed38a88f377eb2267dc3e8816b89a40635 Reviewed-on: https://go-review.googlesource.com/c/go/+/289509 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-02-04[dev.typeparams] cmd/compile/internal/types2: use 512 bits as max. integer ↵Robert Griesemer
precision This matches the compiler's existing limitations and thus ensures that types2 reports the same errors for oversize integer constants. Change-Id: I4fb7c83f3af69098d96f7b6c53dbe3eaf6ea9ee4 Reviewed-on: https://go-review.googlesource.com/c/go/+/288633 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-02-03[dev.typeparams] cmd/compile: refuse excessively long constantsRobert Griesemer
The compiler uses 512 bit of precision for untyped constant arithmetic but didn't restrict the length of incoming constant literals in any way, possibly opening the door for excessively long constants that could bring compilation to a crawl. Add a simple check that refuses excessively long constants. Add test. Change-Id: I797cb2a8e677b8da2864eb92d686d271ab8a004d Reviewed-on: https://go-review.googlesource.com/c/go/+/289049 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-01-30[dev.typeparams] cmd/compile/internal/types2: handle untyped constant ↵Robert Griesemer
arithmetic overflow Factor out the existing "constant representation" check after untyped constant arithmetic and combine with an overflow check. Use a better heuristic for determining the error position if we know the error is for a constant operand that is the result of an arithmetic expression. Related cleanups. With this change, untyped constant arithmetic reports an error when (integer) constants become too large (> 2048 bits). Before, such arithmetic was only limited by space and time. Change-Id: Id3cea66c8ba697ff4c7fd1e848f350d9713e3c75 Reviewed-on: https://go-review.googlesource.com/c/go/+/287832 Trust: Robert Griesemer <gri@golang.org> Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-01-28[dev.typeparams] cmd/compile/internal/types2: translate syntax to token ↵Robert Griesemer
constants via tables This makes the respective files match the respective go/types files a tad more. Change-Id: Ie555e18ed23c493379a1e56b96276867190106f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/287492 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2021-01-21[dev.typeparams] cmd/compile: use nil instead of syntax.ImplicitOneRobert Griesemer
Represent x++/-- as x +=/-= with the RHS of the assignment being nil rather than syntax.ImplicitOne. Dependent code already had to check for syntax.ImplicitOne, but then shared some existing code for regular assignment operations. Now always handle this case fully explicit, which simplifies the code. Change-Id: I28c7918153c27cbbf97b041d0c85ff027c58687c Reviewed-on: https://go-review.googlesource.com/c/go/+/285172 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
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-14[dev.typeparams] cmd/compile/internal/types2: untyped shift counts must fit ↵Robert Griesemer
into uint Updates #43697. Change-Id: If94658cb798bb0434ac3ebbf9dff504dcd59a02a Reviewed-on: https://go-review.googlesource.com/c/go/+/283872 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-14[dev.typeparams] cmd/compile/internal/types2: better error message for ↵Robert Griesemer
invalid ... use This partially addresses the issue below: In many (all) cases we want to handle invalid ... use in the parser as a syntax error; but this ensures that we get a decent error if we get here anyway. Updates #43680. Change-Id: I93af43a5f5741d8bc76e7a13c0db75e6edf43111 Reviewed-on: https://go-review.googlesource.com/c/go/+/283475 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-12-14[dev.typeparams] cmd/compile/internal/types2: don't report two errors for ↵Robert Griesemer
bad strings If the parser reported an error for (string) literals, don't report a second error during type checking. This should have a couple of tests but they are tricky to arrange with the current testing framework as the ERROR comment cannot be on the line where the string. But the change is straightforward and we have test/fixedbugs/issue32133.go that is passing now. Change-Id: I0cd7f002b04e4092b8eb66009c7413288c8bfb23 Reviewed-on: https://go-review.googlesource.com/c/go/+/277993 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>
2020-12-10[dev.typeparams] cmd/compile/internal/types2: report correct line number for ↵Robert Griesemer
missing key Use the Key position of a syntax.KeyValueExpr (not the position of the ":") when reporting an error for a missing key. (In go/types, the KeyValueExpr position is the start of the expression not the ":", so there this works as expected.) Change-Id: I74147d245927847274cf4e53b4f03dbb5110c324 Reviewed-on: https://go-review.googlesource.com/c/go/+/276813 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>
2020-12-09[dev.typeparams] cmd/compile/internal/types2: adjusted more error messages ↵Robert Griesemer
for compiler Triaged and adjusted more test/fixedbugs/* tests. Change-Id: I80b9ead2445bb8d126b7d79db4bea9ddcb225a84 Reviewed-on: https://go-review.googlesource.com/c/go/+/276812 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>
2020-12-09[dev.typeparams] cmd/compile/internal/types2: adjusted array error message ↵Robert Griesemer
for compiler Also: Triaged/adjusted some more test/fixedbugs tests. Change-Id: Idaba1875273d6da6ef82dd8de8edd8daa885d32c Reviewed-on: https://go-review.googlesource.com/c/go/+/276472 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-12-03[dev.typeparams] cmd/compile/internal/types: adjust some error messages to ↵Robert Griesemer
match the compiler Change-Id: I04bd7b294de4ed0fb01bc0609e09debea2d797bd Reviewed-on: https://go-review.googlesource.com/c/go/+/274974 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>
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-11-25[dev.typeparams] cmd/compile/internal/types2: a type parameter is a valid ↵Robert Griesemer
type case in a type switch Likewise for type assertions. This is a port of https://golang.org/cl/273127 to dev.typeparams. Updates #42758. Change-Id: If93246371c3555e067b0043f0caefaac99101ebc Reviewed-on: https://go-review.googlesource.com/c/go/+/273128 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>
2020-11-20[dev.typeparams] cmd/compile/internal/types2: report constant overflow in ↵Robert Griesemer
binary ops This is the go.types changes of https://golang.org/cl/271706 ported to types2. Also: Fixed a bug in the go/types version (was using the wrong position in the error message). Change-Id: I798b80243a66f0be5b943a6951d7a1ff769abca2 Reviewed-on: https://go-review.googlesource.com/c/go/+/271806 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
2020-11-19[dev.typeparams] cmd/compile/internal/types2: report an error for invalid ↵Robert Griesemer
constant values This is https://golang.org/cl/271377 ported to types2. Updates #42695. Change-Id: I475bdcaeace5b0e87d4476a6d660996534289666 Reviewed-on: https://go-review.googlesource.com/c/go/+/271520 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-11-18[dev.typeparams] cmd/compile/internal/types2: port of ↵Robert Griesemer
https://golang.org/cl/270957 This ports the latest updates to the dev.go2go version of types2 to the dev.typeparams version. Change-Id: Ic1b09a8aaeefc701a5c194a587be26e0878e64da Reviewed-on: https://go-review.googlesource.com/c/go/+/270958 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>
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>