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 07a9944ac2
commit 24bf45b25f
4 changed files with 21 additions and 1 deletions
+1
View File
@@ -1,6 +1,7 @@
.*.swo
.*.swp
*.dot
*.out
.idea/
/yaegi
internal/cmd/extract/extract
+9
View File
@@ -0,0 +1,9 @@
package main
func main() {
_ = 1 + 1
println("ok")
}
// Output:
// ok
+10
View File
@@ -0,0 +1,10 @@
package main
func main() {
a, b := 1, 2
_ = a + b
println("ok")
}
// Output:
// ok
+1 -1
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 {