CL 715840 deferred popping from the object path during handling of
grouped declaration statements, which leaves extra objects on the
path since this executes in a loop.
Surprisingly, no test exercised this. This change fixes this small
bug and adds a supporting test.
Fixes #76366
Change-Id: I7fc038b39d3871eea3e60855c46614b463bcfa4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/722060
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Mark Freeman <markfreeman@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
scopePos := s.Name.Pos()
check.declare(check.scope, s.Name, obj, scopePos)
check.push(obj) // mark as grey
- defer check.pop()
check.typeDecl(obj, s, nil)
+ check.pop()
default:
check.errorf(s, InvalidSyntaxTree, "unknown syntax.Decl node %T", s)
scopePos := d.spec.Name.Pos()
check.declare(check.scope, d.spec.Name, obj, scopePos)
check.push(obj) // mark as grey
- defer check.pop()
check.typeDecl(obj, d.spec, nil)
+ check.pop()
default:
check.errorf(d.node(), InvalidSyntaxTree, "unknown ast.Decl node %T", d.node())
}
--- /dev/null
+// Copyright 2025 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+func _() {
+ type (
+ A = int
+ B = []A
+ )
+}