This site is being rebuilt and some pages are out of date. For current details, write to [email protected]. This notice goes away when the rebuild is done.

No analytics unless you allow it, no tracking. This site keeps in your browser the language you pick, the theme, its colour, which site you chose, the currency on the pricing page and that you closed this notice; signing in adds session cookies. The legal page has the details.

Sign in

Radar · Go · Archive · Week 28 · Jul 6 – 12, 2026

go/parser: add deprecated func ResolveFile(*File)

Nice to knowtooling

What changed
A deprecated ResolveFile(*File) function is added to expose the legacy syntactic resolution algorithm used by parser.ParseFile when SkipObjectResolution is false.
Production impact
The source does not say.
Try it
Parse a file with parser.ParseFile and call parser.ResolveFile(f) to see the resolved identifiers.
Source
github.com/golang/go/issues/79802

Understand it, then run it

The Go parser used to resolve identifiers to the objects they refer to while building the syntax tree. That resolution is now considered legacy and is no longer the default. A new function, ResolveFile, is added to expose that old resolution algorithm. It lets you run the legacy resolution on a file that was parsed without it. The change is only a convenience; it does not alter the language or the compiler.

Run it now

Todaygo
// This program demonstrates the legacy syntactic resolution that is performed
// by the Go parser when parsing with the default mode. It parses a small
// source string, walks the AST, and prints the name of the object each
// identifier refers to. The ResolveFile function is not available in Go
// 1.27.1, so we rely on the parser's default behavior.
package main

import (
	"fmt"
	"go/ast"
	"go/parser"
	"go/token"
)

func main() {
	src := `
package main
import "fmt"
func main() {
	x := 42
	fmt.Println(x)
}
`
	fset := token.NewFileSet()
	// ParseFile with default mode (SkipObjectResolution = false)
	file, err := parser.ParseFile(fset, "example.go", src, parser.ParseComments)
	if err != nil {
		panic(err)
	}

	// Walk the AST and print identifier resolution info.
	ast.Inspect(file, func(n ast.Node) bool {
		id, ok := n.(*ast.Ident)
		if !ok {
			return true
		}
		if id.Obj != nil {
			fmt.Printf("Ident %q resolved to object %q\n", id.Name, id.Obj.Name)
		} else {
			fmt.Printf("Ident %q has no resolved object\n", id.Name)
		}
		return true
	})
}

What it printed when we ran it on Go 1.27.1

Ident "main" has no resolved object
Ident "main" resolved to object "main"
Ident "x" resolved to object "x"
Ident "fmt" has no resolved object
Ident "Println" has no resolved object
Ident "x" resolved to object "x"

After the change ships

go · the proposal's code; it does not compile until the change ships

// This code does not compile until the change ships in Go 1.28.
// It demonstrates the use of the new ResolveFile function to perform
// legacy syntactic resolution on a file parsed with SkipObjectResolution.
package main

import (
	"go/ast"
	"go/parser"
	"go/token"
)

func main() {
	fset := token.NewFileSet()
	file, _ := parser.ParseFile(fset, "example.go", nil, parser.SkipObjectResolution)
	parser.ResolveFile(file) // legacy resolution applied
	_ = file // use the resolved file
}

Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.

Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed