Commit 03ec8de2 authored by Robert Griesemer's avatar Robert Griesemer
Browse files

[dev.typeparams] cmd/compile/internal/types2: clean up index expr...

[dev.typeparams] cmd/compile/internal/types2: clean up index expr 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: default avatarRobert Findley <rfindley@google.com>
parent 47547d85
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment