// instantiated types must be sanitized
{`package g0; type t[P any] int; var x struct{ f t[int] }; var _ = x.f`, `x.f`, `g0.t[int]`},
+
+ // issue 45096
+ {`package issue45096; func _[T interface{ type int8, int16, int32 }](x T) { _ = x < 0 }`, `0`, `T₁`},
}
for _, test := range tests {
}
if mode == constant_ {
assert(val != nil)
- assert(typ == Typ[Invalid] || isConstType(typ))
+ // We check is(typ, IsConstType) here as constant expressions may be
+ // recorded as type parameters.
+ assert(typ == Typ[Invalid] || is(typ, IsConstType))
}
if m := check.Types; m != nil {
m[x] = TypeAndValue{mode, typ, val}
for _, t := range unpack(types) {
x := *x // make a copy; convertUntypedInternal modifies x
- check.convertUntypedInternal(&x, t)
+ check.convertUntypedInternal(&x, t, false)
if x.mode == invalid {
goto Error
}
return
}
- check.convertUntypedInternal(x, target)
+ check.convertUntypedInternal(x, target, true)
return
Error:
}
// convertUntypedInternal should only be called by convertUntyped.
-func (check *Checker) convertUntypedInternal(x *operand, target Type) {
+func (check *Checker) convertUntypedInternal(x *operand, target Type, update bool) {
assert(isTyped(target))
if x.isNil() {
return
}
// expression value may have been rounded - update if needed
- check.updateExprVal(x.expr, x.val)
+ if update {
+ check.updateExprVal(x.expr, x.val)
+ }
} else {
// Non-constant untyped values may appear as the
// result of comparisons (untyped bool), intermediate
}
case *Sum:
t.is(func(t Type) bool {
- check.convertUntypedInternal(x, t)
+ check.convertUntypedInternal(x, t, false)
return x.mode != invalid
})
case *Interface:
OK:
x.typ = target
- check.updateExprType(x.expr, target, true)
+ if update {
+ check.updateExprType(x.expr, target, true)
+ }
return
Error: