From 15947d99c9854e5249b0991947dda1422f832ff3 Mon Sep 17 00:00:00 2001 From: Marc Vertes Date: Thu, 8 Jul 2021 09:04:03 +0200 Subject: [PATCH] interp: fix type checking of address of multi dimension array Fixes #1177. --- _test/issue-1177.go | 13 +++++++++++++ interp/typecheck.go | 1 + 2 files changed, 14 insertions(+) create mode 100644 _test/issue-1177.go diff --git a/_test/issue-1177.go b/_test/issue-1177.go new file mode 100644 index 000000000..ea9668afe --- /dev/null +++ b/_test/issue-1177.go @@ -0,0 +1,13 @@ +package main + +type counters [3][16]int + +func main() { + cs := &counters{} + p := &cs[0][1] + *p = 2 + println(cs[0][1]) +} + +// Output: +// 2 diff --git a/interp/typecheck.go b/interp/typecheck.go index 1b8e350e5..b33a64647 100644 --- a/interp/typecheck.go +++ b/interp/typecheck.go @@ -105,6 +105,7 @@ func (check typecheck) addressExpr(n *node) error { c := c0.child[0] if isArray(c.typ) || isMap(c.typ) { c0 = c + found = true continue } case compositeLitExpr, identExpr: