fix: do not panic when assigning to _ (blank) var.

Fix interp.isEmptyInterface to tolerate a nil type.

Fixes #1619
This commit is contained in:
Marc Vertes
2024-04-02 19:18:03 +02:00
committed by GitHub
parent 9aa161f2da
commit 2c92a7c7ab
4 changed files with 21 additions and 1 deletions

1
.gitignore vendored
View File

@@ -1,6 +1,7 @@
.*.swo
.*.swp
*.dot
*.out
.idea/
/yaegi
internal/cmd/extract/extract

9
_test/op10.go Normal file
View File

@@ -0,0 +1,9 @@
package main
func main() {
_ = 1 + 1
println("ok")
}
// Output:
// ok

10
_test/op11.go Normal file
View File

@@ -0,0 +1,10 @@
package main
func main() {
a, b := 1, 2
_ = a + b
println("ok")
}
// Output:
// ok

View File

@@ -2393,7 +2393,7 @@ func isMap(t *itype) bool { return t.TypeOf().Kind() == reflect.Map }
func isPtr(t *itype) bool { return t.TypeOf().Kind() == reflect.Ptr }
func isEmptyInterface(t *itype) bool {
return t.cat == interfaceT && len(t.field) == 0
return t != nil && t.cat == interfaceT && len(t.field) == 0
}
func isGeneric(t *itype) bool {