traefik / yaegi

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

import "github.com/opentracing/opentracing-go" issue #1538

Closed caiuskong closed 1 year ago

caiuskong commented 1 year ago

The following program sample.go triggers an unexpected result

package main

import (
  "fmt"
  "github.com/opentracing/opentracing-go"
)

func main() {
  fmt.Println(opentracing.GlobalTracer())
}

Expected result

{}

Got

scope.go:220: nil type
panic: nil type

goroutine 1 [running]:
log.Panic({0x1400079e448, 0x1, 0x1})
        /opt/hostedtoolcache/go/1.17.5/x64/src/log/log.go:354 +0x98
github.com/traefik/yaegi/interp.(*scope).add(0x140007d5200, 0x0)
        /home/runner/work/yaegi/yaegi/interp/scope.go:220 +0x58
github.com/traefik/yaegi/interp.(*Interpreter).cfg.func1(0x14000379320)
        /home/runner/work/yaegi/yaegi/interp/cfg.go:192 +0x38a8
github.com/traefik/yaegi/interp.(*node).Walk(0x14000379320, 0x1400079ea80, 0x1400079ea48)
        /home/runner/work/yaegi/yaegi/interp/interp.go:285 +0x38
github.com/traefik/yaegi/interp.(*node).Walk(0x14000378ea0, 0x1400079ea80, 0x1400079ea48)
        /home/runner/work/yaegi/yaegi/interp/interp.go:289 +0x88
github.com/traefik/yaegi/interp.(*node).Walk(0x14000378d80, 0x1400079ea80, 0x1400079ea48)
        /home/runner/work/yaegi/yaegi/interp/interp.go:289 +0x88
github.com/traefik/yaegi/interp.(*node).Walk(0x14000378c60, 0x1400079ea80, 0x1400079ea48)
        /home/runner/work/yaegi/yaegi/interp/interp.go:289 +0x88
github.com/traefik/yaegi/interp.(*node).Walk(0x14000377320, 0x1400079ea80, 0x1400079ea48)
        /home/runner/work/yaegi/yaegi/interp/interp.go:289 +0x88
github.com/traefik/yaegi/interp.(*node).Walk(0x14000133200, 0x1400079ea80, 0x1400079ea48)
        /home/runner/work/yaegi/yaegi/interp/interp.go:289 +0x88
github.com/traefik/yaegi/interp.(*Interpreter).cfg(0x14000207b00, 0x14000133200, 0x140007d5200, {0x140001c52c1, 0x25}, {0x1400037d1d0, 0xb})
        /home/runner/work/yaegi/yaegi/interp/cfg.go:62 +0x1ac
github.com/traefik/yaegi/interp.(*Interpreter).importSrc(0x14000207b00, {0x1400037ca88, 0x4}, {0x140001c52c1, 0x25}, 0x1)
        /home/runner/work/yaegi/yaegi/interp/src.go:125 +0x71c
github.com/traefik/yaegi/interp.(*Interpreter).gta.func1(0x140003bd200)
        /home/runner/work/yaegi/yaegi/interp/gta.go:237 +0x1c10
github.com/traefik/yaegi/interp.(*node).Walk(0x140003bd200, 0x1400079f828, 0x0)
        /home/runner/work/yaegi/yaegi/interp/interp.go:285 +0x38
github.com/traefik/yaegi/interp.(*node).Walk(0x140003bca20, 0x1400079f828, 0x0)
        /home/runner/work/yaegi/yaegi/interp/interp.go:289 +0x88
github.com/traefik/yaegi/interp.(*node).Walk(0x140003bc7e0, 0x1400079f828, 0x0)
        /home/runner/work/yaegi/yaegi/interp/interp.go:289 +0x88
github.com/traefik/yaegi/interp.(*Interpreter).gta(0x14000207b00, 0x140003bc7e0, {0x1400037ca88, 0x4}, {0x1400037ca88, 0x4}, {0x1400037ca88, 0x4})
        /home/runner/work/yaegi/yaegi/interp/gta.go:20 +0x17c
github.com/traefik/yaegi/interp.(*Interpreter).gtaRetry(0x14000207b00, {0x1400024fa40, 0x1, 0x1}, {0x1400037ca88, 0x4}, {0x1400037ca88, 0x4})
        /home/runner/work/yaegi/yaegi/interp/gta.go:346 +0x150
github.com/traefik/yaegi/interp.(*Interpreter).CompileAST(0x14000207b00, {0x1037c1a70, 0x140001ceb80})
        /home/runner/work/yaegi/yaegi/interp/program.go:77 +0x184
github.com/traefik/yaegi/interp.(*Interpreter).compileSrc(0x14000207b00, {0x140004aaf00, 0x2182}, {0x16d1dab4d, 0xb}, 0x0)
        /home/runner/work/yaegi/yaegi/interp/program.go:52 +0x110
github.com/traefik/yaegi/interp.(*Interpreter).eval(0x14000207b00, {0x140004aaf00, 0x2182}, {0x16d1dab4d, 0xb}, 0x0)
        /home/runner/work/yaegi/yaegi/interp/interp.go:606 +0x50
github.com/traefik/yaegi/interp.(*Interpreter).EvalPath(0x14000207b00, {0x16d1dab4d, 0xb})
        /home/runner/work/yaegi/yaegi/interp/interp.go:508 +0xe8
main.runFile(0x14000207b00, {0x16d1dab4d, 0xb}, 0x0)
        /home/runner/work/yaegi/yaegi/cmd/yaegi/run.go:153 +0xb0
main.run({0x140001921a0, 0x1, 0x1})
        /home/runner/work/yaegi/yaegi/cmd/yaegi/run.go:116 +0xe14
main.main()
        /home/runner/work/yaegi/yaegi/cmd/yaegi/yaegi.go:133 +0xf4

Yaegi Version

0.11.2

Additional Notes

yaegi 0.15.0 is ok. (But due to some other bugs, I currently need to use 0.11.2)

mvertes commented 1 year ago

We do not maintain old versions of yaegi, sorry. In that case there would be probably too many changes to be applied anyway.

If you have found other bugs in the most recent versions of yaegi, it's better to file new issues for those.

Thank you.