traefik / yaegi

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

package unsafe \"unsafe\" has no symbol Slice" #1604

Open section1Q84 opened 6 months ago

section1Q84 commented 6 months ago

The following program sample.go triggers an unexpected result

package main

import (
  "github.com/traefik/yaegi/stdlib"
  "github.com/traefik/yaegi/stdlib/unsafe"
)

var payload = `
package main

func main() {
  StringToBytes("a")
}
func StringToBytes(s string) []byte {
    return unsafe.Slice(unsafe.StringData(s), len(s))
}
`

func main() {
  i := interp.New(interp.Options{})
  i.Use(stdlib.Symbols)
  i.Use(unsafe.Symbols)
}

Expected result

normal

Got

package unsafe \"unsafe\" has no symbol Slice"

Yaegi Version

latest

Additional Notes

No response