]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/go/ast/scope.go
go/ast: deprecate Object
[gostls13.git] / src / go / ast / scope.go
index 888221200743c63f3570b61a7c008d07925b156e..039ca58bc0920b6eef4844fe9deec624d5cf5bbe 100644 (file)
@@ -15,6 +15,8 @@ import (
 // A Scope maintains the set of named language entities declared
 // in the scope and a link to the immediately surrounding (outer)
 // scope.
+//
+// Deprecated: use the type checker [go/types] instead; see [Object].
 type Scope struct {
        Outer   *Scope
        Objects map[string]*Object
@@ -69,6 +71,19 @@ func (s *Scope) String() string {
 //     Kind    Data type         Data value
 //     Pkg     *Scope            package scope
 //     Con     int               iota for the respective declaration
+//
+// Deprecated: The relationship between Idents and Objects cannot be
+// correctly computed without type information. For example, the
+// expression T{K: 0} may denote a struct, map, slice, or array
+// literal, depending on the type of T. If T is a struct, then K
+// refers to a field of T, whereas for the other types it refers to a
+// value in the environment.
+//
+// New programs should set the [parser.SkipObjectResolution] parser
+// flag to disable syntactic object resolution (which also saves CPU
+// and memory), and instead use the type checker [go/types] if object
+// resolution is desired. See the Defs, Uses, and Implicits fields of
+// the [types.Info] struct for details.
 type Object struct {
        Kind ObjKind
        Name string // declared name