go/types: add tests for conversion of non-constant untyped values

This was fixed by CL 242084. Retroactively add some tests that would
have failed before the fix.

Also, remove some existing duplicate tests.

Change-Id: I95f7a215d4a9651ded6d739f89c574f33f573c60
Reviewed-on: https://go-review.googlesource.com/c/go/+/251397
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This commit is contained in:
Rob Findley 2020-08-28 12:10:31 -04:00 committed by Robert Findley
parent 42e09dc1ba
commit 45e12e95e6
1 changed files with 18 additions and 5 deletions

View File

@ -193,14 +193,27 @@ func shifts6() {
_ = float32(1.0 /* ERROR "must be integer" */ <<s)
_ = float32(1.1 /* ERROR "must be integer" */ <<s)
_ = int32(0x80000000 /* ERROR "overflows int32" */ << s)
// TODO(rfindley) Eliminate the redundant error here.
_ = int32(( /* ERROR "truncated to int32" */ 0x80000000 /* ERROR "truncated to int32" */ + 0i) << s)
_ = int(1+0i<<0)
_ = int((1+0i)<<s)
_ = int(1.0<<s)
_ = int(complex(1, 0)<<s)
_ = int(float32/* ERROR "must be integer" */(1.0) <<s)
_ = int(1.1 /* ERROR must be integer */ <<s)
_ = int(( /* ERROR "must be integer" */ 1+1i) <<s)
_ = complex(1 /* ERROR "must be integer" */ <<s, 0)
var b []int
_ = append(b, 1<<s)
_ = append(b, 1.0<<s)
_ = append(b, (1+0i)<<s)
_ = append(b, 1.1 /* ERROR "must be integer" */ <<s)
_ = append(b, 1<<s)
_ = append(b, 1.0<<s) // should fail - see TODO in append code
_ = append(b, 1.1 /* ERROR "must be integer" */ <<s)
_ = append(b, (1 + 0i) <<s)
_ = append(b, ( /* ERROR "must be integer" */ 1 + 1i) <<s)
_ = complex(1.0 /* ERROR "must be integer" */ <<s, 0)
_ = complex(1.1 /* ERROR "must be integer" */ <<s, 0)
@ -379,4 +392,4 @@ func issue22969() {
var _ int8 = 0xff /* ERROR "overflows int8" */ << s
var _ int16 = 0xffff /* ERROR "overflows int16" */ << s
var _ int32 = 0x80000000 /* ERROR "overflows int32" */ << s
}
}