aboutsummaryrefslogtreecommitdiff
path: root/src/go/parser/parser.go
diff options
context:
space:
mode:
authorRob Findley <rfindley@google.com>2021-03-29 16:03:51 -0400
committerRobert Findley <rfindley@google.com>2021-04-16 21:20:31 +0000
commit02a2ff47ef6004a59e4d688c7c93198778c36bcf (patch)
treeb6b535aba3f09bb6e8bbb69af8dd7ea9811dba4a /src/go/parser/parser.go
parentb91f8a4c0b0b9be44b24b445cbf2955050a55b69 (diff)
downloadgo-02a2ff47ef6004a59e4d688c7c93198778c36bcf.tar.gz
go-02a2ff47ef6004a59e4d688c7c93198778c36bcf.zip
go/parser: add a SkipObjectResolution mode to bypass object resolution
Parser object resolution is an auxiliary feature in which the parser attempts to resolve identifiers to their declarations. In functionality, it significantly overlaps with go/types and in fact cannot be correctly computed at parse-time without type information (for example, it is generally not possible to resolve k in the composite lit c{k: v}). Due to these limitations, it is of limited utility and rarely used. Now that object resolution is isolated as a post-processing pass, it is trivial to offer a parser mode that skips it entirely. This CL adds that mode. Fixes #45104 Change-Id: I5a2c05437e298964ad2039e1ff98e63d6efbd1af Reviewed-on: https://go-review.googlesource.com/c/go/+/306149 Trust: Robert Findley <rfindley@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Diffstat (limited to 'src/go/parser/parser.go')
-rw-r--r--src/go/parser/parser.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/go/parser/parser.go b/src/go/parser/parser.go
index aff5838780..cddaef350e 100644
--- a/src/go/parser/parser.go
+++ b/src/go/parser/parser.go
@@ -2636,7 +2636,9 @@ func (p *parser) parseFile() *ast.File {
if p.mode&DeclarationErrors != 0 {
declErr = p.error
}
- resolveFile(f, p.file, declErr)
+ if p.mode&SkipObjectResolution == 0 {
+ resolveFile(f, p.file, declErr)
+ }
return f
}