traefik / yaegi

Yaegi is Another Elegant Go Interpreter
https://pkg.go.dev/github.com/traefik/yaegi
Apache License 2.0
6.94k stars 343 forks source link

nil and slice equality is incorrect #1496

Closed elee1766 closed 1 year ago

elee1766 commented 1 year ago

The following program test.go triggers an unexpected result

package main

import "fmt"

func main() {
    a := []byte{} == nil
    b := nil == []byte{}

    fmt.Printf("ans: %v\n", a)
    fmt.Printf("ans: %v\n", b)
}

Expected result

λ go run ./test.go                                                                                                                             
ans: false
ans: false

Got

λ yaegi ./test.go                                                                                                                              
ans: false
ans: true

Yaegi Version

eee72d1aae664bf6627ef955215d886dc7b105c0

Additional Notes

[]byte{} == nil and nil == []byte{} should both be false

however, yaegi thinks that nil == []byte{}