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

`interp/type.go` can return a `nil` value (and no error, either) in `nodetype2`, which causes a panic #1636

Open theclapp opened 1 month ago

theclapp commented 1 month ago

The following program sample.go triggers an unexpected result

n/a

Expected result

Error

Got

panic

Yaegi Version

381e045

Additional Notes

I'm having a hard time reproducing this at the moment, but the t == nil line in the below snippet from interp/type.go allows returning a nil value from nodetype2, which lots of places use without checking if it's nil (including right inside nodetype2), which causes a panic:

https://github.com/traefik/yaegi/blob/381e045966b079ca0ac364ba111fcb603226a74b/interp/type.go#L1119-L1127

I suspect that me hitting this case was a result of using Yaegi incorrectly (possibly from using ImportUsed but not actually importing those packages in the Eval'ed code), which I'm not doing any more, which is why I'm not seeing it, but I feel like the t == nil case should clearly at least return an error.