yaegi
yaegi copied to clipboard
panics when compiling a script with syntax error
The following program sample.go
triggers an unexpected result
package main
import (
"context"
)
func main() {
checkImpl(context)
}
func checkImpl(ctx context.Context) {
// intentionally left blank
}
Expected result
# command-line-arguments
./sample.go:8:12: use of package context not in selector
Got
panic: runtime error: invalid memory address or nil pointer dereference [recovered]
panic: ./sample.go:8:2: CFG post-order panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x13d96e0]
goroutine 1 [running]:
github.com/traefik/yaegi/interp.(*Interpreter).cfg.func2.1()
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/cfg.go:601 +0x78
panic({0x19ef600, 0x219afc0})
/usr/local/go/src/runtime/panic.go:890 +0x263
github.com/traefik/yaegi/interp.(*itype).assignableTo(0xc0003fa3c0, 0xc0003fa640)
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/type.go:1465 +0x1a0
github.com/traefik/yaegi/interp.typecheck.assignment({0xc0003fa780?}, 0xc0003f92c0, 0x2383a68?, {0x0, 0x0})
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/typecheck.go:57 +0x1c5
github.com/traefik/yaegi/interp.typecheck.argument({0xc0001b22b8?}, {0xc0003f92c0?, 0x0?}, 0xc0003fa780, 0x0, 0x1, 0x0)
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/typecheck.go:1015 +0x3cd
github.com/traefik/yaegi/interp.typecheck.arguments({0x0?}, 0x0?, {0xc00020ea78?, 0x1, 0x133d427?}, 0xc0003f9180, 0x0)
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/typecheck.go:970 +0x292
github.com/traefik/yaegi/interp.(*Interpreter).cfg.func2(0xc0003f9040)
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/cfg.go:1317 +0xaa4e
github.com/traefik/yaegi/interp.(*node).Walk(0xc0003f9040, 0xc0002218e8, 0xc000221930)
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/interp.go:294 +0xad
github.com/traefik/yaegi/interp.(*node).Walk(0xc0003f8f00, 0xc0002218e8, 0xc000221930)
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/interp.go:291 +0x75
github.com/traefik/yaegi/interp.(*node).Walk(0xc0003f8dc0, 0xc0002218e8, 0xc000221930)
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/interp.go:291 +0x75
github.com/traefik/yaegi/interp.(*node).Walk(0xc0003f8640, 0xc0002218e8, 0xc000221930)
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/interp.go:291 +0x75
github.com/traefik/yaegi/interp.(*node).Walk(0xc0003f8000, 0xc0002218e8, 0xc000221930)
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/interp.go:291 +0x75
github.com/traefik/yaegi/interp.(*Interpreter).cfg(0xc0001e58c0, 0xc0003f8000, 0xc0001e0510, {0xc0002c4898, 0x4}, {0xc0002c4898, 0x4})
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/cfg.go:62 +0x2b4
github.com/traefik/yaegi/interp.(*Interpreter).CompileAST(0xc0001e58c0, {0x1c95898?, 0xc0001e0360?})
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/program.go:97 +0x1ad
github.com/traefik/yaegi/interp.(*Interpreter).compileSrc(0xc0001e58c0, {0xc000290ab0?, 0x8f?}, {0x7ff7bfeff87b?, 0xc000186600?}, 0xb0?)
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/program.go:64 +0xb8
github.com/traefik/yaegi/interp.(*Interpreter).eval(0xc0001e58c0, {0xc000290ab0?, 0x8f?}, {0x7ff7bfeff87b?, 0x200?}, 0x90?)
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/interp.go:556 +0x28
github.com/traefik/yaegi/interp.(*Interpreter).EvalPath(0xc0001e58c0, {0x7ff7bfeff87b, 0xb})
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/interp/interp.go:514 +0xab
main.runFile(0x7ff7bfeff87b?, {0x7ff7bfeff87b, 0xb}, 0x0)
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/cmd/yaegi/run.go:153 +0xee
main.run({0xc000198010?, 0x1, 0x1})
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/cmd/yaegi/run.go:116 +0xb9a
main.main()
/Users/bytedance/go/pkg/mod/github.com/traefik/[email protected]/cmd/yaegi/yaegi.go:144 +0x2cb
exit status 2
Yaegi Version
v0.15.1
Additional Notes
No response