Skip to content

Commit

Permalink
fix: do not panic when assigning to _ (blank) var.
Browse files Browse the repository at this point in the history
Fix interp.isEmptyInterface to tolerate a nil type.

Fixes #1619
  • Loading branch information
mvertes committed Apr 2, 2024
1 parent 9aa161f commit 2c92a7c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
.*.swo
.*.swp
*.dot
*.out
.idea/
/yaegi
internal/cmd/extract/extract
Expand Down
9 changes: 9 additions & 0 deletions _test/op10.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package main

func main() {
_ = 1 + 1
println("ok")
}

// Output:
// ok
10 changes: 10 additions & 0 deletions _test/op11.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package main

func main() {
a, b := 1, 2
_ = a + b
println("ok")
}

// Output:
// ok
2 changes: 1 addition & 1 deletion interp/type.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 2c92a7c

Please sign in to comment.