interp: fix support of type assert expressions in the global scope
Add the support of type assert expressions in type parsing which allows to process type assertions in the global scope. Fixes #1543.
This commit is contained in:
11
_test/assert4.go
Normal file
11
_test/assert4.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
var cc interface{} = 2
|
||||
var dd = cc.(int)
|
||||
|
||||
func main() {
|
||||
println(dd)
|
||||
}
|
||||
|
||||
// Output:
|
||||
// 2
|
||||
@@ -1093,6 +1093,9 @@ func nodeType2(interp *Interpreter, sc *scope, n *node, seen []*node) (t *itype,
|
||||
sc.sym[sname].typ = t
|
||||
}
|
||||
|
||||
case typeAssertExpr:
|
||||
t, err = nodeType2(interp, sc, n.child[1], seen)
|
||||
|
||||
default:
|
||||
err = n.cfgErrorf("type definition not implemented: %s", n.kind)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user