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

interp: fix type assertion issues #1524

Closed ssbeatty closed 1 year ago

ssbeatty commented 1 year ago

closes #1514

hi! I had the same problem as #1514 and I wanted to fix it, I found When asserting *crypto/rsa.PublicKey, using the typ attribute of node to get an nil rtype, resulting in the assertion result being nok

This code contains the same problem

package main

import (
    "log"
    "crypto/rsa"
)

func main() {

    var pKey interface{} = &rsa.PublicKey{}

    if _, ok := pKey.(*rsa.PublicKey); ok {
        log.Println("ok")
    } else {
        log.Println("nok")
    }
}

So I submitted this Pull Request, hope it will be merged

CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

ssbeatty commented 1 year ago

Thank you very much for your reply, I added new test file for this use case