@@ -75,6 +75,9 @@ func (interp *Interpreter) cfg(root *node, importPath string) ([]*node, error) {
|
||||
case assignStmt, defineStmt:
|
||||
a := n.anc
|
||||
i := childPos(n) - a.nright
|
||||
if i < 0 {
|
||||
break
|
||||
}
|
||||
if len(a.child) > a.nright+a.nleft {
|
||||
i--
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ func TestEvalAssign(t *testing.T) {
|
||||
{src: "f := int64(3.2)", err: "1:39: cannot convert expression of type float64 to type int64"},
|
||||
{src: "g := 1; g <<= 8", res: "256"},
|
||||
{src: "h := 1; h >>= 8", res: "0"},
|
||||
{src: "i := 1; j := &i; (*j) = 2", res: "2"},
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user