code: func (tc *typeChecker) CheckBody(env *TypeEnv, body Body) (*TypeEnv, Errors) {
  
  	if env == nil {
  		env = NewTypeEnv()
  	} else {
  		env = env.wrap()
  	}
  
  	WalkExprs(body, func(expr *Expr) bool {
  
  		closureErrs := tc.checkClosures(env, expr)
  		for _, err := range closureErrs {
  			tc.err(err)
  		}
  
  		hasClosureErrors := len(closureErrs) > 0
  
  		vis := newRefChecker(env)
  		Walk(vis, expr)
  		for _, err := range vis.errs {
  			tc.err(err)
  		}
  
  		hasRefErrors := len(vis.errs) > 0
  
  		if err := tc.checkExpr(env, expr); err != nil {
  			// Suppress this error if a more actionable one has occurred. In
  			// this case, if an error occurred in a ref or closure contained in
  			// this expression, and the error is due to a nil type, then it's
  			// likely to be the result of the more specific error.
  			skip := (hasClosureErrors || hasRefErrors) && causedByNilType(err)
  			if !skip {
  				tc.err(err)
  			}
  		}
  
  		return true
  	})
  
  	return env, tc.errs
  }
docs: // CheckBody runs type checking on the body and returns a TypeEnv if no errors
  // are found. The resulting TypeEnv wraps the provided one. The resulting
  // TypeEnv will be able to resolve types of vars contained in the body.