aboutsummaryrefslogtreecommitdiff
path: root/test/typeparam/factimp.dir
diff options
context:
space:
mode:
authorDan Scales <danscales@google.com>2021-06-02 00:03:25 -0700
committerDan Scales <danscales@google.com>2021-06-02 23:10:42 +0000
commit97cb0113a358a24931bc91c956da0cb023f2776c (patch)
tree0baa45bac527ebaecc3b0eee3e1de3ac53b4cca1 /test/typeparam/factimp.dir
parent6b1cdeaef3099b32d244cef7bb5adc4d7b7628fc (diff)
downloadgo-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/factimp.dir')
-rw-r--r--test/typeparam/factimp.dir/a.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/test/typeparam/factimp.dir/a.go b/test/typeparam/factimp.dir/a.go
index e11575e66e..3552474382 100644
--- a/test/typeparam/factimp.dir/a.go
+++ b/test/typeparam/factimp.dir/a.go
@@ -5,8 +5,8 @@
package a
func Fact[T interface { type int, int64, float64 }](n T) T {
- if n == T(1) {
- return T(1)
+ if n == 1 {
+ return 1
}
- return n * Fact(n - T(1))
+ return n * Fact(n - 1)
}