Skip to content

Commit

Permalink
interp: fix parsing of assign to dereferenced pointer
Browse files Browse the repository at this point in the history
Fixes #969.
  • Loading branch information
mvertes authored Nov 30, 2020
1 parent b25ee3f commit 662d2a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
3 changes: 3 additions & 0 deletions interp/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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--
}
Expand Down
1 change: 1 addition & 0 deletions interp/interp_eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
})
}

Expand Down

0 comments on commit 662d2a6

Please sign in to comment.