fix: add support for out of order declarations of empty global variables
This commit is contained in:
committed by
Traefiker Bot
parent
3645904a15
commit
058c121273
8
_test/fun8.go
Normal file
8
_test/fun8.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package main
|
||||
|
||||
func main() { println(f == nil) }
|
||||
|
||||
var f func()
|
||||
|
||||
// Output:
|
||||
// true
|
||||
@@ -72,8 +72,15 @@ func (interp *Interpreter) gta(root *node, rpath string) ([]*node, error) {
|
||||
err = compDefineX(sc, n)
|
||||
|
||||
case valueSpec:
|
||||
// TODO: handle global ValueSpec
|
||||
//err = n.cfgError("global ValueSpec not implemented")
|
||||
l := len(n.child) - 1
|
||||
if n.typ = n.child[l].typ; n.typ == nil {
|
||||
if n.typ, err = nodeType(interp, sc, n.child[l]); err != nil {
|
||||
return false
|
||||
}
|
||||
}
|
||||
for _, c := range n.child[:l] {
|
||||
sc.sym[c.ident] = &symbol{index: sc.add(n.typ), kind: varSym, global: true, typ: n.typ}
|
||||
}
|
||||
|
||||
case funcDecl:
|
||||
if n.typ, err = nodeType(interp, sc, n.child[2]); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user