Fix type detection in variable declaration

This commit is contained in:
Marc Vertes
2018-11-14 18:03:02 +01:00
parent 0b67bb3f6f
commit c9519a6a0e
3 changed files with 4 additions and 3 deletions

View File

@@ -20,6 +20,7 @@ const (
var symKinds = [...]string{
Const: "Const",
Typ: "Typ",
Var: "Var",
Func: "Func",
Bin: "Bin",
@@ -1067,7 +1068,7 @@ func isNewDefine(n *Node) bool {
if n.anc.kind == RangeStmt && (n.anc.child[0] == n || n.anc.child[1] == n) {
return true
}
if n.anc.kind == ValueSpec {
if n.anc.kind == ValueSpec && n.anc.child[0] == n {
return true
}
return false

View File

@@ -236,7 +236,7 @@ func assign(n *Node) {
}
}
// assign0 implements assignement of zero value
// assign0 implements assignement of zero value, as in a var statement
func assign0(n *Node) {
l := len(n.child) - 1
zero := n.typ.zero

View File

@@ -58,7 +58,7 @@ func (interp *Interpreter) importSrcFile(path string) {
// Once all package sources have been parsed, execute entry points then init functions
for _, n := range rootNodes {
genRun(n)
//interp.fsize++
interp.fsize++
interp.resizeFrame()
interp.run(n, nil)
}