package main
// Reproducer: tinygo interp panics with "comparing values of different size"
// when a package-level initializer makes an interface method call on a
// receiver whose underlying type is narrower than a pointer.
//
// The $invoke thunk widens the receiver to pointer size via ptrtoint, but the
// method body compares it against a constant of the declared width, so
// interp's rawValue.equal gets a 4-byte lhs and a 1-byte rhs.
//
// tinygo build -target=pico -o=/dev/null .
type handle interface{ id() int }
type narrow uint8 // uint16 also fails; uintptr-width does not
func (h narrow) id() int {
if h == 1 {
return 10
}
return 0
}
var h handle = narrow(1)
var n = h.id() // evaluated by interp at compile time
func main() { println(n) }