fix: blank identifier cause panic (#255)

This commit is contained in:
Cuong Manh Le
2019-07-25 01:20:04 +07:00
committed by Ludovic Fernandez
parent 172d4a4657
commit f2034819c2
2 changed files with 10 additions and 1 deletions

9
_test/assign8.go Normal file
View File

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

View File

@@ -343,7 +343,7 @@ func (interp *Interpreter) cfg(root *node) ([]*node, error) {
dest, src := n.child[i], n.child[sbase+i]
var sym *symbol
var level int
if n.kind == defineStmt {
if n.kind == defineStmt || (n.kind == assignStmt && dest.ident == "_") {
if src.typ != nil && src.typ.cat == nilT {
err = src.cfgErrorf("use of untyped nil")
break