• Robert Griesemer's avatar
    go/ast, go/parser: populate identifier scopes at parse time · 021b040a
    Robert Griesemer authored
    The parser populates all scopes for a given file (except
    type-related scopes for structs, interfaces, and methods
    of types) at parse time.
    
    A new parser flag, DeclarationErrors, enables error messages
    related to declaration errors (as far as it is possible to
    provide them).
    
    The resulting AST has all (non-field, non-method) identifiers
    resolved that can be resolved w/o doing imports or parsing
    missing package files.
    
    The ast.File node contains the (partially complete)
    package scope and a list of unresolved global identifiers.
    
    All type-specific data structures have been removed from the AST.
    
    The existing typechecker is functional but needs to be adjusted
    (simplified) accordingly. Utility functions to resolve all
    identifiers for a package (after handling imports and parsing
    all package files) are  missing.
    
    Unrelated changes:
    - Rename typechecker/testdata files to that they are not considered
      by gofmt.
    - Minor cleanups/simplifications.
    
    Parses all .go files in src and misc without declaration errors.
    Runs all tests. Changes do not affect gofmt output.
    
    R=rsc
    CC=golang-dev
    https://golang.org/cl/4244049
    021b040a
stmt_test.go 14.6 KB