The problem has to do with the fact that untyped constants are treated differently in type inference.
Note that `slices.Index(mySlice, int(1))` also does not work. That's because 1 has no type - it is an untyped integer constant - while int(1) has the type int.
Untyped constants can be assigned to multiple different types, so they need to be treated differently. We wouldn't, for example, want this to fail to compile:
type MyInt int
var x []MyInt
slices.Index(x, 1)
On the other hand, a constant of type `int` - or a struct-literal of type `MyStruct` - can only ever have one type (even if that type is assignable to interfaces as well).
In order to make type-inference relatively easy to understand and specify, the compiler doesn't do any backtracking or whatever. So when it sees `slices.Index(s, x)` and it needs to figure out what `S` (constrained on `~[]E`) and `E` (constraint on any) is, and it sees that `x` already has a definitive type, it kind of greedily binds `E` to that type and then just checks if the rest of the type parameters work out.
With an untyped constant, it *doesn't* immediately see what `E` can be, but it *does* see that `S` has to be `[]any`, so it binds that, forcing `E` to be `any. And then it checks if the untyped constant works with that.
The outcome is a bit confusing, true. But it's a consequence of keeping inference rules relatively simple. And as inference is optional and it is always possible to actively specify the constraints you have in mind, the design is conservative with what it tries to do automatically.