diff --git a/go/types/conversions.go b/go/types/conversions.go index f7b2a567cb4..6e279ca3ee5 100644 --- a/go/types/conversions.go +++ b/go/types/conversions.go @@ -20,7 +20,7 @@ func (check *Checker) conversion(x *operand, T Type) { switch t := T.Underlying().(*Basic); { case representableConst(x.val, check.conf, t.kind, &x.val): ok = true - case x.isInteger() && isString(t): + case isInteger(x.typ) && isString(t): codepoint := int64(-1) if i, ok := exact.Int64Val(x.val); ok { codepoint = i diff --git a/go/types/testdata/conversions.src b/go/types/testdata/conversions.src index 4251424646e..e1336c0456a 100644 --- a/go/types/testdata/conversions.src +++ b/go/types/testdata/conversions.src @@ -32,6 +32,11 @@ func string_conversions() { const _ = string(true /* ERROR "cannot convert" */ ) const _ = string(1.2 /* ERROR "cannot convert" */ ) const _ = string(nil /* ERROR "cannot convert" */ ) + + // issues 11357, 11353: argument must be of integer type + _ = string(0.0 /* ERROR "cannot convert" */ ) + _ = string(0i /* ERROR "cannot convert" */ ) + _ = string(1 /* ERROR "cannot convert" */ + 2i) } func interface_conversions() {