Open
Description
Problem
Interfaces are not comparable. This problem is aggravated by the fact errors usually need to be compared to control program flow, i.e. io.EOF.
The following program yields an error when flashing/building
package main
type A uint8
func (a A) Error() string {
return "got error"
}
func main() {
var a A = 12
var b error = a
if b == a {
println("oh no, an error!")
}
}
Output
$ tinygo build -o=.bin -target=arduino-nano enc28j60/test/main.go
/tmp/tinygo304709431/main.o: In function `(reflect.Value).Complex':
/usr/local/lib/tinygo/src/reflect/value.go:271: undefined reference to `__extendsfdf2'
/usr/local/lib/tinygo/src/reflect/value.go:271: undefined reference to `__extendsfdf2'
/tmp/tinygo304709431/main.o: In function `(reflect.Value).Float':
/usr/local/lib/tinygo/src/reflect/value.go:245: undefined reference to `__extendsfdf2'
/tmp/tinygo304709431/main.o: In function `runtime.reflectValueEqual':
/usr/local/lib/tinygo/src/runtime/interface.go:55: undefined reference to `__eqdf2'
/usr/local/lib/tinygo/src/runtime/interface.go:55: undefined reference to `__eqdf2'
/usr/local/lib/tinygo/src/runtime/interface.go:53: undefined reference to `__eqdf2'
collect2: error: ld returned 1 exit status
error: failed to link /tmp/tinygo304709431/main: exit status 1
Error happens on the following boards as well
arduino
arduino-mega2566
Below is a MWE of the error, same error message too:
package main
type Aer interface {
abc()
}
type A uint8
func (a A) abc() {}
func main() {
var a Aer = A(12)
var b Aer = a
if b == a {
println("oh no, an error!")
}
}