diff options
author | Dan Scales <danscales@google.com> | 2021-06-02 00:03:25 -0700 |
---|---|---|
committer | Dan Scales <danscales@google.com> | 2021-06-02 23:10:42 +0000 |
commit | 97cb0113a358a24931bc91c956da0cb023f2776c (patch) | |
tree | 0baa45bac527ebaecc3b0eee3e1de3ac53b4cca1 /test/typeparam/listimp.dir | |
parent | 6b1cdeaef3099b32d244cef7bb5adc4d7b7628fc (diff) | |
download | go-97cb0113a358a24931bc91c956da0cb023f2776c.tar.gz go-97cb0113a358a24931bc91c956da0cb023f2776c.zip |
[dev.typeparams] cmd/compile: fix export/import of constants with typeparam type
A constant will have a TYPEPARAM type if it appears in a place where it
must match that typeparam type (e.g. in a binary operation with a
variable of that typeparam type). If so, then we must write out its
actual constant kind as well, so its constant val can be read in
properly during import.
Fixed some export/import tests which were casting some untyped constants
to avoid this problem.
Change-Id: I285ad8f1c8febbe526769c96e6b27acbd23050f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/324189
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Diffstat (limited to 'test/typeparam/listimp.dir')
-rw-r--r-- | test/typeparam/listimp.dir/a.go | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/test/typeparam/listimp.dir/a.go b/test/typeparam/listimp.dir/a.go index a4118a0e81..0a4634b7be 100644 --- a/test/typeparam/listimp.dir/a.go +++ b/test/typeparam/listimp.dir/a.go @@ -42,11 +42,10 @@ type ListNum[T OrderedNum] struct { const Clip = 5 // clippedLargest returns the largest in the list of OrderNums, but a max of 5. -// TODO(danscales): fix export/import of an untype constant with typeparam type func (l *ListNum[T]) ClippedLargest() T { var max T for p := l; p != nil; p = p.Next { - if p.Val > max && p.Val < T(Clip) { + if p.Val > max && p.Val < Clip { max = p.Val } } |