func (p *Program) Parse() error {
	// Load all imports
	for _, pkg := range p.Sorted() {
		err := pkg.importRecursively()
		if err != nil {
			if err, ok := err.(*ImportCycleError); ok {
				if pkg.ImportPath != err.Packages[0] {
					err.Packages = append([]string{pkg.ImportPath}, err.Packages...)
				}
			}
			return err
		}
	}

	// Parse all packages.
	for _, pkg := range p.Sorted() {
		err := pkg.Parse()
		if err != nil {
			return err
		}
	}

	// Typecheck all packages.
	for _, pkg := range p.Sorted() {
		err := pkg.Check()
		if err != nil {
			return err
		}
	}

	return nil
}
// Parse recursively imports all packages, parses them, and typechecks them.
//
// The returned error may be an Errors error, which contains a list of errors.
//
// Idempotent.
Parse recursively imports all packages, parses them, and typechecks them.

The returned error may be an Errors error, which contains a list of errors.

Idempotent.
// Parse recursively imports all packages parses them and typechecks them . // // The returned error may be an Errors error which contains a list of errors . // // Idempotent .
func (p *Program) Parse() error {
	for _, pkg := range p.Sorted() {
		err := pkg.importRecursively()
		if err != nil {
			if err, ok := err.(*ImportCycleError); ok {
				if pkg.ImportPath != err.Packages[0] {
					err.Packages = append([]string{pkg.ImportPath}, err.Packages...)
				}
			}
			return err
		}
	}
	for _, pkg := range p.Sorted() {
		err := pkg.Parse()
		if err != nil {
			return err
		}
	}
	for _, pkg := range p.Sorted() {
		err := pkg.Check()
		if err != nil {
			return err
		}
	}
	return nil
}
func ( p * Program ) Parse ( ) error { for _ , pkg := range p . Sorted ( ) { err := pkg . importRecursively ( ) if err != nil { if err , ok := err . ( * ImportCycleError ) ; ok { if pkg . ImportPath != err . Packages [ 0 ] { err . Packages = append ( [ ] string { pkg . ImportPath } , err . Packages ... ) } } return err } } for _ , pkg := range p . Sorted ( ) { err := pkg . Parse ( ) if err != nil { return err } } for _ , pkg := range p . Sorted ( ) { err := pkg . Check ( ) if err != nil { return err } } return nil }
Parse recursively imports all packages, parses them, and typechecks them.
Parse recursively imports all packages parses them and typechecks them .
// Load all imports // Parse all packages. // Typecheck all packages.