]> Cypherpunks repositories - gostls13.git/commitdiff
internal/types/errors: export error codes
authorRobert Griesemer <gri@golang.org>
Thu, 6 Oct 2022 21:08:14 +0000 (14:08 -0700)
committerGopher Robot <gobot@golang.org>
Mon, 10 Oct 2022 15:21:10 +0000 (15:21 +0000)
Adjust self-test accordingly.

Change-Id: I69987a306760da9eaf832275af0e9a8b6131a349
Reviewed-on: https://go-review.googlesource.com/c/go/+/439561
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/internal/types/errors/codes.go
src/internal/types/errors/codes_test.go

index 3546c652432fa06d36e91eec08986c43ddd7660d..cdb6c5a99048ede2354b67b6d3b7c8cf32e79896 100644 (file)
@@ -4,7 +4,7 @@
 
 package errors
 
-type errorCode int
+type Code int
 
 // This file defines the error codes that can be produced during type-checking.
 // Collectively, these codes provide an identifier that may be used to
@@ -31,97 +31,97 @@ type errorCode int
 // problem with types.
 
 const (
-       _ errorCode = iota
+       _ Code = iota
 
-       // _Test is reserved for errors that only apply while in self-test mode.
-       _Test
+       // Test is reserved for errors that only apply while in self-test mode.
+       Test
 
-       // _BlankPkgName occurs when a package name is the blank identifier "_".
+       // BlankPkgName occurs when a package name is the blank identifier "_".
        //
        // Per the spec:
        //  "The PackageName must not be the blank identifier."
-       _BlankPkgName
+       BlankPkgName
 
-       // _MismatchedPkgName occurs when a file's package name doesn't match the
+       // MismatchedPkgName occurs when a file's package name doesn't match the
        // package name already established by other files.
-       _MismatchedPkgName
+       MismatchedPkgName
 
-       // _InvalidPkgUse occurs when a package identifier is used outside of a
+       // InvalidPkgUse occurs when a package identifier is used outside of a
        // selector expression.
        //
        // Example:
        //  import "fmt"
        //
        //  var _ = fmt
-       _InvalidPkgUse
+       InvalidPkgUse
 
-       // _BadImportPath occurs when an import path is not valid.
-       _BadImportPath
+       // BadImportPath occurs when an import path is not valid.
+       BadImportPath
 
-       // _BrokenImport occurs when importing a package fails.
+       // BrokenImport occurs when importing a package fails.
        //
        // Example:
        //  import "amissingpackage"
-       _BrokenImport
+       BrokenImport
 
-       // _ImportCRenamed occurs when the special import "C" is renamed. "C" is a
+       // ImportCRenamed occurs when the special import "C" is renamed. "C" is a
        // pseudo-package, and must not be renamed.
        //
        // Example:
        //  import _ "C"
-       _ImportCRenamed
+       ImportCRenamed
 
-       // _UnusedImport occurs when an import is unused.
+       // UnusedImport occurs when an import is unused.
        //
        // Example:
        //  import "fmt"
        //
        //  func main() {}
-       _UnusedImport
+       UnusedImport
 
-       // _InvalidInitCycle occurs when an invalid cycle is detected within the
+       // InvalidInitCycle occurs when an invalid cycle is detected within the
        // initialization graph.
        //
        // Example:
        //  var x int = f()
        //
        //  func f() int { return x }
-       _InvalidInitCycle
+       InvalidInitCycle
 
-       // _DuplicateDecl occurs when an identifier is declared multiple times.
+       // DuplicateDecl occurs when an identifier is declared multiple times.
        //
        // Example:
        //  var x = 1
        //  var x = 2
-       _DuplicateDecl
+       DuplicateDecl
 
-       // _InvalidDeclCycle occurs when a declaration cycle is not valid.
+       // InvalidDeclCycle occurs when a declaration cycle is not valid.
        //
        // Example:
        //  type S struct {
        //      S
        //  }
        //
-       _InvalidDeclCycle
+       InvalidDeclCycle
 
-       // _InvalidTypeCycle occurs when a cycle in type definitions results in a
+       // InvalidTypeCycle occurs when a cycle in type definitions results in a
        // type that is not well-defined.
        //
        // Example:
        //  import "unsafe"
        //
        //  type T [unsafe.Sizeof(T{})]int
-       _InvalidTypeCycle
+       InvalidTypeCycle
 
-       // _InvalidConstInit occurs when a const declaration has a non-constant
+       // InvalidConstInit occurs when a const declaration has a non-constant
        // initializer.
        //
        // Example:
        //  var x int
        //  const _ = x
-       _InvalidConstInit
+       InvalidConstInit
 
-       // _InvalidConstVal occurs when a const value cannot be converted to its
+       // InvalidConstVal occurs when a const value cannot be converted to its
        // target type.
        //
        // TODO(findleyr): this error code and example are not very clear. Consider
@@ -129,31 +129,31 @@ const (
        //
        // Example:
        //  const _ = 1 << "hello"
-       _InvalidConstVal
+       InvalidConstVal
 
-       // _InvalidConstType occurs when the underlying type in a const declaration
+       // InvalidConstType occurs when the underlying type in a const declaration
        // is not a valid constant type.
        //
        // Example:
        //  const c *int = 4
-       _InvalidConstType
+       InvalidConstType
 
-       // _UntypedNil occurs when the predeclared (untyped) value nil is used to
+       // UntypedNil occurs when the predeclared (untyped) value nil is used to
        // initialize a variable declared without an explicit type.
        //
        // Example:
        //  var x = nil
-       _UntypedNil
+       UntypedNil
 
-       // _WrongAssignCount occurs when the number of values on the right-hand side
+       // WrongAssignCount occurs when the number of values on the right-hand side
        // of an assignment or initialization expression does not match the number
        // of variables on the left-hand side.
        //
        // Example:
        //  var x = 1, 2
-       _WrongAssignCount
+       WrongAssignCount
 
-       // _UnassignableOperand occurs when the left-hand side of an assignment is
+       // UnassignableOperand occurs when the left-hand side of an assignment is
        // not assignable.
        //
        // Example:
@@ -161,9 +161,9 @@ const (
        //      const c = 1
        //      c = 2
        //  }
-       _UnassignableOperand
+       UnassignableOperand
 
-       // _NoNewVar occurs when a short variable declaration (':=') does not declare
+       // NoNewVar occurs when a short variable declaration (':=') does not declare
        // new variables.
        //
        // Example:
@@ -171,9 +171,9 @@ const (
        //      x := 1
        //      x := 2
        //  }
-       _NoNewVar
+       NoNewVar
 
-       // _MultiValAssignOp occurs when an assignment operation (+=, *=, etc) does
+       // MultiValAssignOp occurs when an assignment operation (+=, *=, etc) does
        // not have single-valued left-hand or right-hand side.
        //
        // Per the spec:
@@ -186,9 +186,9 @@ const (
        //      x, y += 1
        //      return x + y
        //  }
-       _MultiValAssignOp
+       MultiValAssignOp
 
-       // _InvalidIfaceAssign occurs when a value of type T is used as an
+       // InvalidIfaceAssign occurs when a value of type T is used as an
        // interface, but T does not implement a method of the expected interface.
        //
        // Example:
@@ -199,9 +199,9 @@ const (
        //  type T int
        //
        //  var x I = T(1)
-       _InvalidIfaceAssign
+       InvalidIfaceAssign
 
-       // _InvalidChanAssign occurs when a chan assignment is invalid.
+       // InvalidChanAssign occurs when a chan assignment is invalid.
        //
        // Per the spec, a value x is assignable to a channel type T if:
        //  "x is a bidirectional channel value, T is a channel type, x's type V and
@@ -215,18 +215,18 @@ const (
        //  var x T1
        //  // Invalid assignment because both types are named
        //  var _ T2 = x
-       _InvalidChanAssign
+       InvalidChanAssign
 
-       // _IncompatibleAssign occurs when the type of the right-hand side expression
+       // IncompatibleAssign occurs when the type of the right-hand side expression
        // in an assignment cannot be assigned to the type of the variable being
        // assigned.
        //
        // Example:
        //  var x []int
        //  var _ int = x
-       _IncompatibleAssign
+       IncompatibleAssign
 
-       // _UnaddressableFieldAssign occurs when trying to assign to a struct field
+       // UnaddressableFieldAssign occurs when trying to assign to a struct field
        // in a map value.
        //
        // Example:
@@ -234,25 +234,25 @@ const (
        //      m := make(map[string]struct{i int})
        //      m["foo"].i = 42
        //  }
-       _UnaddressableFieldAssign
+       UnaddressableFieldAssign
 
-       // _NotAType occurs when the identifier used as the underlying type in a type
+       // NotAType occurs when the identifier used as the underlying type in a type
        // declaration or the right-hand side of a type alias does not denote a type.
        //
        // Example:
        //  var S = 2
        //
        //  type T S
-       _NotAType
+       NotAType
 
-       // _InvalidArrayLen occurs when an array length is not a constant value.
+       // InvalidArrayLen occurs when an array length is not a constant value.
        //
        // Example:
        //  var n = 3
        //  var _ = [n]int{}
-       _InvalidArrayLen
+       InvalidArrayLen
 
-       // _BlankIfaceMethod occurs when a method name is '_'.
+       // BlankIfaceMethod occurs when a method name is '_'.
        //
        // Per the spec:
        //  "The name of each explicitly specified method must be unique and not
@@ -262,9 +262,9 @@ const (
        //  type T interface {
        //      _(int)
        //  }
-       _BlankIfaceMethod
+       BlankIfaceMethod
 
-       // _IncomparableMapKey occurs when a map key type does not support the == and
+       // IncomparableMapKey occurs when a map key type does not support the == and
        // != operators.
        //
        // Per the spec:
@@ -275,13 +275,13 @@ const (
        //  var x map[T]int
        //
        //  type T []int
-       _IncomparableMapKey
+       IncomparableMapKey
 
-       // _InvalidIfaceEmbed occurs when a non-interface type is embedded in an
+       // InvalidIfaceEmbed occurs when a non-interface type is embedded in an
        // interface (for go 1.17 or earlier).
        _ // not used anymore
 
-       // _InvalidPtrEmbed occurs when an embedded field is of the pointer form *T,
+       // InvalidPtrEmbed occurs when an embedded field is of the pointer form *T,
        // and T itself is itself a pointer, an unsafe.Pointer, or an interface.
        //
        // Per the spec:
@@ -294,25 +294,25 @@ const (
        //  type S struct {
        //      *T
        //  }
-       _InvalidPtrEmbed
+       InvalidPtrEmbed
 
-       // _BadRecv occurs when a method declaration does not have exactly one
+       // BadRecv occurs when a method declaration does not have exactly one
        // receiver parameter.
        //
        // Example:
        //  func () _() {}
-       _BadRecv
+       BadRecv
 
-       // _InvalidRecv occurs when a receiver type expression is not of the form T
+       // InvalidRecv occurs when a receiver type expression is not of the form T
        // or *T, or T is a pointer type.
        //
        // Example:
        //  type T struct {}
        //
        //  func (**T) m() {}
-       _InvalidRecv
+       InvalidRecv
 
-       // _DuplicateFieldAndMethod occurs when an identifier appears as both a field
+       // DuplicateFieldAndMethod occurs when an identifier appears as both a field
        // and method name.
        //
        // Example:
@@ -321,18 +321,18 @@ const (
        //  }
        //
        //  func (T) m() {}
-       _DuplicateFieldAndMethod
+       DuplicateFieldAndMethod
 
-       // _DuplicateMethod occurs when two methods on the same receiver type have
+       // DuplicateMethod occurs when two methods on the same receiver type have
        // the same name.
        //
        // Example:
        //  type T struct {}
        //  func (T) m() {}
        //  func (T) m(i int) int { return i }
-       _DuplicateMethod
+       DuplicateMethod
 
-       // _InvalidBlank occurs when a blank identifier is used as a value or type.
+       // InvalidBlank occurs when a blank identifier is used as a value or type.
        //
        // Per the spec:
        //  "The blank identifier may appear as an operand only on the left-hand side
@@ -340,29 +340,29 @@ const (
        //
        // Example:
        //  var x = _
-       _InvalidBlank
+       InvalidBlank
 
-       // _InvalidIota occurs when the predeclared identifier iota is used outside
+       // InvalidIota occurs when the predeclared identifier iota is used outside
        // of a constant declaration.
        //
        // Example:
        //  var x = iota
-       _InvalidIota
+       InvalidIota
 
-       // _MissingInitBody occurs when an init function is missing its body.
+       // MissingInitBody occurs when an init function is missing its body.
        //
        // Example:
        //  func init()
-       _MissingInitBody
+       MissingInitBody
 
-       // _InvalidInitSig occurs when an init function declares parameters or
+       // InvalidInitSig occurs when an init function declares parameters or
        // results.
        //
        // Deprecated: no longer emitted by the type checker. _InvalidInitDecl is
        // used instead.
-       _InvalidInitSig
+       InvalidInitSig
 
-       // _InvalidInitDecl occurs when init is declared as anything other than a
+       // InvalidInitDecl occurs when init is declared as anything other than a
        // function.
        //
        // Example:
@@ -370,13 +370,13 @@ const (
        //
        // Example:
        //  func init() int { return 1 }
-       _InvalidInitDecl
+       InvalidInitDecl
 
-       // _InvalidMainDecl occurs when main is declared as anything other than a
+       // InvalidMainDecl occurs when main is declared as anything other than a
        // function, in a main package.
-       _InvalidMainDecl
+       InvalidMainDecl
 
-       // _TooManyValues occurs when a function returns too many values for the
+       // TooManyValues occurs when a function returns too many values for the
        // expression context in which it is used.
        //
        // Example:
@@ -385,9 +385,9 @@ const (
        //  }
        //
        //  var x = ReturnTwo()
-       _TooManyValues
+       TooManyValues
 
-       // _NotAnExpr occurs when a type expression is used where a value expression
+       // NotAnExpr occurs when a type expression is used where a value expression
        // is expected.
        //
        // Example:
@@ -396,46 +396,46 @@ const (
        //  func f() {
        //      T
        //  }
-       _NotAnExpr
+       NotAnExpr
 
-       // _TruncatedFloat occurs when a float constant is truncated to an integer
+       // TruncatedFloat occurs when a float constant is truncated to an integer
        // value.
        //
        // Example:
        //  var _ int = 98.6
-       _TruncatedFloat
+       TruncatedFloat
 
-       // _NumericOverflow occurs when a numeric constant overflows its target type.
+       // NumericOverflow occurs when a numeric constant overflows its target type.
        //
        // Example:
        //  var x int8 = 1000
-       _NumericOverflow
+       NumericOverflow
 
-       // _UndefinedOp occurs when an operator is not defined for the type(s) used
+       // UndefinedOp occurs when an operator is not defined for the type(s) used
        // in an operation.
        //
        // Example:
        //  var c = "a" - "b"
-       _UndefinedOp
+       UndefinedOp
 
-       // _MismatchedTypes occurs when operand types are incompatible in a binary
+       // MismatchedTypes occurs when operand types are incompatible in a binary
        // operation.
        //
        // Example:
        //  var a = "hello"
        //  var b = 1
        //  var c = a - b
-       _MismatchedTypes
+       MismatchedTypes
 
-       // _DivByZero occurs when a division operation is provable at compile
+       // DivByZero occurs when a division operation is provable at compile
        // time to be a division by zero.
        //
        // Example:
        //  const divisor = 0
        //  var x int = 1/divisor
-       _DivByZero
+       DivByZero
 
-       // _NonNumericIncDec occurs when an increment or decrement operator is
+       // NonNumericIncDec occurs when an increment or decrement operator is
        // applied to a non-numeric value.
        //
        // Example:
@@ -443,32 +443,32 @@ const (
        //      var c = "c"
        //      c++
        //  }
-       _NonNumericIncDec
+       NonNumericIncDec
 
-       // _UnaddressableOperand occurs when the & operator is applied to an
+       // UnaddressableOperand occurs when the & operator is applied to an
        // unaddressable expression.
        //
        // Example:
        //  var x = &1
-       _UnaddressableOperand
+       UnaddressableOperand
 
-       // _InvalidIndirection occurs when a non-pointer value is indirected via the
+       // InvalidIndirection occurs when a non-pointer value is indirected via the
        // '*' operator.
        //
        // Example:
        //  var x int
        //  var y = *x
-       _InvalidIndirection
+       InvalidIndirection
 
-       // _NonIndexableOperand occurs when an index operation is applied to a value
+       // NonIndexableOperand occurs when an index operation is applied to a value
        // that cannot be indexed.
        //
        // Example:
        //  var x = 1
        //  var y = x[1]
-       _NonIndexableOperand
+       NonIndexableOperand
 
-       // _InvalidIndex occurs when an index argument is not of integer type,
+       // InvalidIndex occurs when an index argument is not of integer type,
        // negative, or out-of-bounds.
        //
        // Example:
@@ -483,16 +483,16 @@ const (
        //  var s = []int{1,2,3}
        //  var i string
        //  var _ = s[i]
-       _InvalidIndex
+       InvalidIndex
 
-       // _SwappedSliceIndices occurs when constant indices in a slice expression
+       // SwappedSliceIndices occurs when constant indices in a slice expression
        // are decreasing in value.
        //
        // Example:
        //  var _ = []int{1,2,3}[2:1]
-       _SwappedSliceIndices
+       SwappedSliceIndices
 
-       // _NonSliceableOperand occurs when a slice operation is applied to a value
+       // NonSliceableOperand occurs when a slice operation is applied to a value
        // whose type is not sliceable, or is unaddressable.
        //
        // Example:
@@ -501,17 +501,17 @@ const (
        // Example:
        //  var x = 1
        //  var y = 1[:1]
-       _NonSliceableOperand
+       NonSliceableOperand
 
-       // _InvalidSliceExpr occurs when a three-index slice expression (a[x:y:z]) is
+       // InvalidSliceExpr occurs when a three-index slice expression (a[x:y:z]) is
        // applied to a string.
        //
        // Example:
        //  var s = "hello"
        //  var x = s[1:2:3]
-       _InvalidSliceExpr
+       InvalidSliceExpr
 
-       // _InvalidShiftCount occurs when the right-hand side of a shift operation is
+       // InvalidShiftCount occurs when the right-hand side of a shift operation is
        // either non-integer, negative, or too large.
        //
        // Example:
@@ -519,16 +519,16 @@ const (
        //      x string
        //      y int = 1 << x
        //  )
-       _InvalidShiftCount
+       InvalidShiftCount
 
-       // _InvalidShiftOperand occurs when the shifted operand is not an integer.
+       // InvalidShiftOperand occurs when the shifted operand is not an integer.
        //
        // Example:
        //  var s = "hello"
        //  var x = s << 2
-       _InvalidShiftOperand
+       InvalidShiftOperand
 
-       // _InvalidReceive occurs when there is a channel receive from a value that
+       // InvalidReceive occurs when there is a channel receive from a value that
        // is either not a channel, or is a send-only channel.
        //
        // Example:
@@ -536,9 +536,9 @@ const (
        //      var x = 1
        //      <-x
        //  }
-       _InvalidReceive
+       InvalidReceive
 
-       // _InvalidSend occurs when there is a channel send to a value that is not a
+       // InvalidSend occurs when there is a channel send to a value that is not a
        // channel, or is a receive-only channel.
        //
        // Example:
@@ -546,9 +546,9 @@ const (
        //      var x = 1
        //      x <- "hello!"
        //  }
-       _InvalidSend
+       InvalidSend
 
-       // _DuplicateLitKey occurs when an index is duplicated in a slice, array, or
+       // DuplicateLitKey occurs when an index is duplicated in a slice, array, or
        // map literal.
        //
        // Example:
@@ -556,67 +556,67 @@ const (
        //
        // Example:
        //  var _ = map[string]int{"a": 1, "a": 2}
-       _DuplicateLitKey
+       DuplicateLitKey
 
-       // _MissingLitKey occurs when a map literal is missing a key expression.
+       // MissingLitKey occurs when a map literal is missing a key expression.
        //
        // Example:
        //  var _ = map[string]int{1}
-       _MissingLitKey
+       MissingLitKey
 
-       // _InvalidLitIndex occurs when the key in a key-value element of a slice or
+       // InvalidLitIndex occurs when the key in a key-value element of a slice or
        // array literal is not an integer constant.
        //
        // Example:
        //  var i = 0
        //  var x = []string{i: "world"}
-       _InvalidLitIndex
+       InvalidLitIndex
 
-       // _OversizeArrayLit occurs when an array literal exceeds its length.
+       // OversizeArrayLit occurs when an array literal exceeds its length.
        //
        // Example:
        //  var _ = [2]int{1,2,3}
-       _OversizeArrayLit
+       OversizeArrayLit
 
-       // _MixedStructLit occurs when a struct literal contains a mix of positional
+       // MixedStructLit occurs when a struct literal contains a mix of positional
        // and named elements.
        //
        // Example:
        //  var _ = struct{i, j int}{i: 1, 2}
-       _MixedStructLit
+       MixedStructLit
 
-       // _InvalidStructLit occurs when a positional struct literal has an incorrect
+       // InvalidStructLit occurs when a positional struct literal has an incorrect
        // number of values.
        //
        // Example:
        //  var _ = struct{i, j int}{1,2,3}
-       _InvalidStructLit
+       InvalidStructLit
 
-       // _MissingLitField occurs when a struct literal refers to a field that does
+       // MissingLitField occurs when a struct literal refers to a field that does
        // not exist on the struct type.
        //
        // Example:
        //  var _ = struct{i int}{j: 2}
-       _MissingLitField
+       MissingLitField
 
-       // _DuplicateLitField occurs when a struct literal contains duplicated
+       // DuplicateLitField occurs when a struct literal contains duplicated
        // fields.
        //
        // Example:
        //  var _ = struct{i int}{i: 1, i: 2}
-       _DuplicateLitField
+       DuplicateLitField
 
-       // _UnexportedLitField occurs when a positional struct literal implicitly
+       // UnexportedLitField occurs when a positional struct literal implicitly
        // assigns an unexported field of an imported type.
-       _UnexportedLitField
+       UnexportedLitField
 
-       // _InvalidLitField occurs when a field name is not a valid identifier.
+       // InvalidLitField occurs when a field name is not a valid identifier.
        //
        // Example:
        //  var _ = struct{i int}{1: 1}
-       _InvalidLitField
+       InvalidLitField
 
-       // _UntypedLit occurs when a composite literal omits a required type
+       // UntypedLit occurs when a composite literal omits a required type
        // identifier.
        //
        // Example:
@@ -625,9 +625,9 @@ const (
        //  }
        //
        //  var _ = outer{inner: {1}}
-       _UntypedLit
+       UntypedLit
 
-       // _InvalidLit occurs when a composite literal expression does not match its
+       // InvalidLit occurs when a composite literal expression does not match its
        // type.
        //
        // Example:
@@ -635,9 +635,9 @@ const (
        //      x int
        //  }
        //  var _ = P {}
-       _InvalidLit
+       InvalidLit
 
-       // _AmbiguousSelector occurs when a selector is ambiguous.
+       // AmbiguousSelector occurs when a selector is ambiguous.
        //
        // Example:
        //  type E1 struct { i int }
@@ -646,50 +646,50 @@ const (
        //
        //  var x T
        //  var _ = x.i
-       _AmbiguousSelector
+       AmbiguousSelector
 
-       // _UndeclaredImportedName occurs when a package-qualified identifier is
+       // UndeclaredImportedName occurs when a package-qualified identifier is
        // undeclared by the imported package.
        //
        // Example:
        //  import "go/types"
        //
        //  var _ = types.NotAnActualIdentifier
-       _UndeclaredImportedName
+       UndeclaredImportedName
 
-       // _UnexportedName occurs when a selector refers to an unexported identifier
+       // UnexportedName occurs when a selector refers to an unexported identifier
        // of an imported package.
        //
        // Example:
        //  import "reflect"
        //
        //  type _ reflect.flag
-       _UnexportedName
+       UnexportedName
 
-       // _UndeclaredName occurs when an identifier is not declared in the current
+       // UndeclaredName occurs when an identifier is not declared in the current
        // scope.
        //
        // Example:
        //  var x T
-       _UndeclaredName
+       UndeclaredName
 
-       // _MissingFieldOrMethod occurs when a selector references a field or method
+       // MissingFieldOrMethod occurs when a selector references a field or method
        // that does not exist.
        //
        // Example:
        //  type T struct {}
        //
        //  var x = T{}.f
-       _MissingFieldOrMethod
+       MissingFieldOrMethod
 
-       // _BadDotDotDotSyntax occurs when a "..." occurs in a context where it is
+       // BadDotDotDotSyntax occurs when a "..." occurs in a context where it is
        // not valid.
        //
        // Example:
        //  var _ = map[int][...]int{0: {}}
-       _BadDotDotDotSyntax
+       BadDotDotDotSyntax
 
-       // _NonVariadicDotDotDot occurs when a "..." is used on the final argument to
+       // NonVariadicDotDotDot occurs when a "..." is used on the final argument to
        // a non-variadic function.
        //
        // Example:
@@ -703,26 +703,26 @@ const (
        //      s := []string{"a", "b", "c"}
        //      printArgs(s...)
        //  }
-       _NonVariadicDotDotDot
+       NonVariadicDotDotDot
 
-       // _MisplacedDotDotDot occurs when a "..." is used somewhere other than the
+       // MisplacedDotDotDot occurs when a "..." is used somewhere other than the
        // final argument in a function declaration.
        //
        // Example:
        //      func f(...int, int)
-       _MisplacedDotDotDot
+       MisplacedDotDotDot
 
-       _ // _InvalidDotDotDotOperand was removed.
+       _ // InvalidDotDotDotOperand was removed.
 
-       // _InvalidDotDotDot occurs when a "..." is used in a non-variadic built-in
+       // InvalidDotDotDot occurs when a "..." is used in a non-variadic built-in
        // function.
        //
        // Example:
        //  var s = []int{1, 2, 3}
        //  var l = len(s...)
-       _InvalidDotDotDot
+       InvalidDotDotDot
 
-       // _UncalledBuiltin occurs when a built-in function is used as a
+       // UncalledBuiltin occurs when a built-in function is used as a
        // function-valued expression, instead of being called.
        //
        // Per the spec:
@@ -731,16 +731,16 @@ const (
        //
        // Example:
        //  var _ = copy
-       _UncalledBuiltin
+       UncalledBuiltin
 
-       // _InvalidAppend occurs when append is called with a first argument that is
+       // InvalidAppend occurs when append is called with a first argument that is
        // not a slice.
        //
        // Example:
        //  var _ = append(1, 2)
-       _InvalidAppend
+       InvalidAppend
 
-       // _InvalidCap occurs when an argument to the cap built-in function is not of
+       // InvalidCap occurs when an argument to the cap built-in function is not of
        // supported type.
        //
        // See https://golang.org/ref/spec#Length_and_capacity for information on
@@ -749,9 +749,9 @@ const (
        // Example:
        //  var s = 2
        //  var x = cap(s)
-       _InvalidCap
+       InvalidCap
 
-       // _InvalidClose occurs when close(...) is called with an argument that is
+       // InvalidClose occurs when close(...) is called with an argument that is
        // not of channel type, or that is a receive-only channel.
        //
        // Example:
@@ -759,9 +759,9 @@ const (
        //      var x int
        //      close(x)
        //  }
-       _InvalidClose
+       InvalidClose
 
-       // _InvalidCopy occurs when the arguments are not of slice type or do not
+       // InvalidCopy occurs when the arguments are not of slice type or do not
        // have compatible type.
        //
        // See https://golang.org/ref/spec#Appending_and_copying_slices for more
@@ -773,16 +773,16 @@ const (
        //      y := []int64{1,2,3}
        //      copy(x, y)
        //  }
-       _InvalidCopy
+       InvalidCopy
 
-       // _InvalidComplex occurs when the complex built-in function is called with
+       // InvalidComplex occurs when the complex built-in function is called with
        // arguments with incompatible types.
        //
        // Example:
        //  var _ = complex(float32(1), float64(2))
-       _InvalidComplex
+       InvalidComplex
 
-       // _InvalidDelete occurs when the delete built-in function is called with a
+       // InvalidDelete occurs when the delete built-in function is called with a
        // first argument that is not a map.
        //
        // Example:
@@ -790,16 +790,16 @@ const (
        //      m := "hello"
        //      delete(m, "e")
        //  }
-       _InvalidDelete
+       InvalidDelete
 
-       // _InvalidImag occurs when the imag built-in function is called with an
+       // InvalidImag occurs when the imag built-in function is called with an
        // argument that does not have complex type.
        //
        // Example:
        //  var _ = imag(int(1))
-       _InvalidImag
+       InvalidImag
 
-       // _InvalidLen occurs when an argument to the len built-in function is not of
+       // InvalidLen occurs when an argument to the len built-in function is not of
        // supported type.
        //
        // See https://golang.org/ref/spec#Length_and_capacity for information on
@@ -808,40 +808,40 @@ const (
        // Example:
        //  var s = 2
        //  var x = len(s)
-       _InvalidLen
+       InvalidLen
 
-       // _SwappedMakeArgs occurs when make is called with three arguments, and its
+       // SwappedMakeArgs occurs when make is called with three arguments, and its
        // length argument is larger than its capacity argument.
        //
        // Example:
        //  var x = make([]int, 3, 2)
-       _SwappedMakeArgs
+       SwappedMakeArgs
 
-       // _InvalidMake occurs when make is called with an unsupported type argument.
+       // InvalidMake occurs when make is called with an unsupported type argument.
        //
        // See https://golang.org/ref/spec#Making_slices_maps_and_channels for
        // information on the types that may be created using make.
        //
        // Example:
        //  var x = make(int)
-       _InvalidMake
+       InvalidMake
 
-       // _InvalidReal occurs when the real built-in function is called with an
+       // InvalidReal occurs when the real built-in function is called with an
        // argument that does not have complex type.
        //
        // Example:
        //  var _ = real(int(1))
-       _InvalidReal
+       InvalidReal
 
-       // _InvalidAssert occurs when a type assertion is applied to a
+       // InvalidAssert occurs when a type assertion is applied to a
        // value that is not of interface type.
        //
        // Example:
        //  var x = 1
        //  var _ = x.(float64)
-       _InvalidAssert
+       InvalidAssert
 
-       // _ImpossibleAssert occurs for a type assertion x.(T) when the value x of
+       // ImpossibleAssert occurs for a type assertion x.(T) when the value x of
        // interface cannot have dynamic type T, due to a missing or mismatching
        // method on T.
        //
@@ -854,9 +854,9 @@ const (
        //
        //  var x I
        //  var _ = x.(T)
-       _ImpossibleAssert
+       ImpossibleAssert
 
-       // _InvalidConversion occurs when the argument type cannot be converted to the
+       // InvalidConversion occurs when the argument type cannot be converted to the
        // target.
        //
        // See https://golang.org/ref/spec#Conversions for the rules of
@@ -865,17 +865,17 @@ const (
        // Example:
        //  var x float64
        //  var _ = string(x)
-       _InvalidConversion
+       InvalidConversion
 
-       // _InvalidUntypedConversion occurs when there is no valid implicit
+       // InvalidUntypedConversion occurs when there is no valid implicit
        // conversion from an untyped value satisfying the type constraints of the
        // context in which it is used.
        //
        // Example:
        //  var _ = 1 + new(int)
-       _InvalidUntypedConversion
+       InvalidUntypedConversion
 
-       // _BadOffsetofSyntax occurs when unsafe.Offsetof is called with an argument
+       // BadOffsetofSyntax occurs when unsafe.Offsetof is called with an argument
        // that is not a selector expression.
        //
        // Example:
@@ -883,9 +883,9 @@ const (
        //
        //  var x int
        //  var _ = unsafe.Offsetof(x)
-       _BadOffsetofSyntax
+       BadOffsetofSyntax
 
-       // _InvalidOffsetof occurs when unsafe.Offsetof is called with a method
+       // InvalidOffsetof occurs when unsafe.Offsetof is called with a method
        // selector, rather than a field selector, or when the field is embedded via
        // a pointer.
        //
@@ -911,42 +911,42 @@ const (
        //
        //  var s S
        //  var _ = unsafe.Offsetof(s.m)
-       _InvalidOffsetof
+       InvalidOffsetof
 
-       // _UnusedExpr occurs when a side-effect free expression is used as a
+       // UnusedExpr occurs when a side-effect free expression is used as a
        // statement. Such a statement has no effect.
        //
        // Example:
        //  func f(i int) {
        //      i*i
        //  }
-       _UnusedExpr
+       UnusedExpr
 
-       // _UnusedVar occurs when a variable is declared but unused.
+       // UnusedVar occurs when a variable is declared but unused.
        //
        // Example:
        //  func f() {
        //      x := 1
        //  }
-       _UnusedVar
+       UnusedVar
 
-       // _MissingReturn occurs when a function with results is missing a return
+       // MissingReturn occurs when a function with results is missing a return
        // statement.
        //
        // Example:
        //  func f() int {}
-       _MissingReturn
+       MissingReturn
 
-       // _WrongResultCount occurs when a return statement returns an incorrect
+       // WrongResultCount occurs when a return statement returns an incorrect
        // number of values.
        //
        // Example:
        //  func ReturnOne() int {
        //      return 1, 2
        //  }
-       _WrongResultCount
+       WrongResultCount
 
-       // _OutOfScopeResult occurs when the name of a value implicitly returned by
+       // OutOfScopeResult occurs when the name of a value implicitly returned by
        // an empty return statement is shadowed in a nested scope.
        //
        // Example:
@@ -958,9 +958,9 @@ const (
        //      }
        //      return 0
        //  }
-       _OutOfScopeResult
+       OutOfScopeResult
 
-       // _InvalidCond occurs when an if condition is not a boolean expression.
+       // InvalidCond occurs when an if condition is not a boolean expression.
        //
        // Example:
        //  func checkReturn(i int) {
@@ -968,20 +968,20 @@ const (
        //              panic("non-zero return")
        //      }
        //  }
-       _InvalidCond
+       InvalidCond
 
-       // _InvalidPostDecl occurs when there is a declaration in a for-loop post
+       // InvalidPostDecl occurs when there is a declaration in a for-loop post
        // statement.
        //
        // Example:
        //  func f() {
        //      for i := 0; i < 10; j := 0 {}
        //  }
-       _InvalidPostDecl
+       InvalidPostDecl
 
-       _ // _InvalidChanRange was removed.
+       _ // InvalidChanRange was removed.
 
-       // _InvalidIterVar occurs when two iteration variables are used while ranging
+       // InvalidIterVar occurs when two iteration variables are used while ranging
        // over a channel.
        //
        // Example:
@@ -990,9 +990,9 @@ const (
        //              println(k, v)
        //      }
        //  }
-       _InvalidIterVar
+       InvalidIterVar
 
-       // _InvalidRangeExpr occurs when the type of a range expression is not array,
+       // InvalidRangeExpr occurs when the type of a range expression is not array,
        // slice, string, map, or channel.
        //
        // Example:
@@ -1001,18 +1001,18 @@ const (
        //              println(j)
        //      }
        //  }
-       _InvalidRangeExpr
+       InvalidRangeExpr
 
-       // _MisplacedBreak occurs when a break statement is not within a for, switch,
+       // MisplacedBreak occurs when a break statement is not within a for, switch,
        // or select statement of the innermost function definition.
        //
        // Example:
        //  func f() {
        //      break
        //  }
-       _MisplacedBreak
+       MisplacedBreak
 
-       // _MisplacedContinue occurs when a continue statement is not within a for
+       // MisplacedContinue occurs when a continue statement is not within a for
        // loop of the innermost function definition.
        //
        // Example:
@@ -1029,9 +1029,9 @@ const (
        //      }
        //      return sum
        //  }
-       _MisplacedContinue
+       MisplacedContinue
 
-       // _MisplacedFallthrough occurs when a fallthrough statement is not within an
+       // MisplacedFallthrough occurs when a fallthrough statement is not within an
        // expression switch.
        //
        // Example:
@@ -1044,9 +1044,9 @@ const (
        //      }
        //      return "unsupported"
        //  }
-       _MisplacedFallthrough
+       MisplacedFallthrough
 
-       // _DuplicateCase occurs when a type or expression switch has duplicate
+       // DuplicateCase occurs when a type or expression switch has duplicate
        // cases.
        //
        // Example:
@@ -1058,9 +1058,9 @@ const (
        //              println("One")
        //      }
        //  }
-       _DuplicateCase
+       DuplicateCase
 
-       // _DuplicateDefault occurs when a type or expression switch has multiple
+       // DuplicateDefault occurs when a type or expression switch has multiple
        // default clauses.
        //
        // Example:
@@ -1074,9 +1074,9 @@ const (
        //              println("1")
        //      }
        //  }
-       _DuplicateDefault
+       DuplicateDefault
 
-       // _BadTypeKeyword occurs when a .(type) expression is used anywhere other
+       // BadTypeKeyword occurs when a .(type) expression is used anywhere other
        // than a type switch.
        //
        // Example:
@@ -1085,18 +1085,18 @@ const (
        //  }
        //  var t I
        //  var _ = t.(type)
-       _BadTypeKeyword
+       BadTypeKeyword
 
-       // _InvalidTypeSwitch occurs when .(type) is used on an expression that is
+       // InvalidTypeSwitch occurs when .(type) is used on an expression that is
        // not of interface type.
        //
        // Example:
        //  func f(i int) {
        //      switch x := i.(type) {}
        //  }
-       _InvalidTypeSwitch
+       InvalidTypeSwitch
 
-       // _InvalidExprSwitch occurs when a switch expression is not comparable.
+       // InvalidExprSwitch occurs when a switch expression is not comparable.
        //
        // Example:
        //  func _() {
@@ -1104,9 +1104,9 @@ const (
        //      switch a /* ERROR cannot switch on a */ {
        //      }
        //  }
-       _InvalidExprSwitch
+       InvalidExprSwitch
 
-       // _InvalidSelectCase occurs when a select case is not a channel send or
+       // InvalidSelectCase occurs when a select case is not a channel send or
        // receive.
        //
        // Example:
@@ -1118,17 +1118,17 @@ const (
        //              return false
        //      }
        //  }
-       _InvalidSelectCase
+       InvalidSelectCase
 
-       // _UndeclaredLabel occurs when an undeclared label is jumped to.
+       // UndeclaredLabel occurs when an undeclared label is jumped to.
        //
        // Example:
        //  func f() {
        //      goto L
        //  }
-       _UndeclaredLabel
+       UndeclaredLabel
 
-       // _DuplicateLabel occurs when a label is declared more than once.
+       // DuplicateLabel occurs when a label is declared more than once.
        //
        // Example:
        //  func f() int {
@@ -1136,9 +1136,9 @@ const (
        //  L:
        //      return 1
        //  }
-       _DuplicateLabel
+       DuplicateLabel
 
-       // _MisplacedLabel occurs when a break or continue label is not on a for,
+       // MisplacedLabel occurs when a break or continue label is not on a for,
        // switch, or select statement.
        //
        // Example:
@@ -1152,17 +1152,17 @@ const (
        //              println(a)
        //      }
        //  }
-       _MisplacedLabel
+       MisplacedLabel
 
-       // _UnusedLabel occurs when a label is declared and not used.
+       // UnusedLabel occurs when a label is declared and not used.
        //
        // Example:
        //  func f() {
        //  L:
        //  }
-       _UnusedLabel
+       UnusedLabel
 
-       // _JumpOverDecl occurs when a label jumps over a variable declaration.
+       // JumpOverDecl occurs when a label jumps over a variable declaration.
        //
        // Example:
        //  func f() int {
@@ -1172,9 +1172,9 @@ const (
        //      x++
        //      return x
        //  }
-       _JumpOverDecl
+       JumpOverDecl
 
-       // _JumpIntoBlock occurs when a forward jump goes to a label inside a nested
+       // JumpIntoBlock occurs when a forward jump goes to a label inside a nested
        // block.
        //
        // Example:
@@ -1185,9 +1185,9 @@ const (
        //              print("inside block")
        //      }
        // }
-       _JumpIntoBlock
+       JumpIntoBlock
 
-       // _InvalidMethodExpr occurs when a pointer method is called but the argument
+       // InvalidMethodExpr occurs when a pointer method is called but the argument
        // is not addressable.
        //
        // Example:
@@ -1196,25 +1196,25 @@ const (
        //  func (*T) m() int { return 1 }
        //
        //  var _ = T.m(T{})
-       _InvalidMethodExpr
+       InvalidMethodExpr
 
-       // _WrongArgCount occurs when too few or too many arguments are passed by a
+       // WrongArgCount occurs when too few or too many arguments are passed by a
        // function call.
        //
        // Example:
        //  func f(i int) {}
        //  var x = f()
-       _WrongArgCount
+       WrongArgCount
 
-       // _InvalidCall occurs when an expression is called that is not of function
+       // InvalidCall occurs when an expression is called that is not of function
        // type.
        //
        // Example:
        //  var x = "x"
        //  var y = x()
-       _InvalidCall
+       InvalidCall
 
-       // _UnusedResults occurs when a restricted expression-only built-in function
+       // UnusedResults occurs when a restricted expression-only built-in function
        // is suspended via go or defer. Such a suspension discards the results of
        // these side-effect free built-in functions, and therefore is ineffectual.
        //
@@ -1223,9 +1223,9 @@ const (
        //      defer len(a)
        //      return i
        //  }
-       _UnusedResults
+       UnusedResults
 
-       // _InvalidDefer occurs when a deferred expression is not a function call,
+       // InvalidDefer occurs when a deferred expression is not a function call,
        // for example if the expression is a type conversion.
        //
        // Example:
@@ -1233,9 +1233,9 @@ const (
        //      defer int32(i)
        //      return i
        //  }
-       _InvalidDefer
+       InvalidDefer
 
-       // _InvalidGo occurs when a go expression is not a function call, for example
+       // InvalidGo occurs when a go expression is not a function call, for example
        // if the expression is a type conversion.
        //
        // Example:
@@ -1243,23 +1243,23 @@ const (
        //      go int32(i)
        //      return i
        //  }
-       _InvalidGo
+       InvalidGo
 
        // All codes below were added in Go 1.17.
 
-       // _BadDecl occurs when a declaration has invalid syntax.
-       _BadDecl
+       // BadDecl occurs when a declaration has invalid syntax.
+       BadDecl
 
-       // _RepeatedDecl occurs when an identifier occurs more than once on the left
+       // RepeatedDecl occurs when an identifier occurs more than once on the left
        // hand side of a short variable declaration.
        //
        // Example:
        //  func _() {
        //      x, y, y := 1, 2, 3
        //  }
-       _RepeatedDecl
+       RepeatedDecl
 
-       // _InvalidUnsafeAdd occurs when unsafe.Add is called with a
+       // InvalidUnsafeAdd occurs when unsafe.Add is called with a
        // length argument that is not of integer type.
        // It also occurs if it is used in a package compiled for a
        // language version before go1.17.
@@ -1269,9 +1269,9 @@ const (
        //
        //  var p unsafe.Pointer
        //  var _ = unsafe.Add(p, float64(1))
-       _InvalidUnsafeAdd
+       InvalidUnsafeAdd
 
-       // _InvalidUnsafeSlice occurs when unsafe.Slice is called with a
+       // InvalidUnsafeSlice occurs when unsafe.Slice is called with a
        // pointer argument that is not of pointer type or a length argument
        // that is not of integer type, negative, or out of bounds.
        // It also occurs if it is used in a package compiled for a language
@@ -1300,24 +1300,24 @@ const (
        //
        //  var x int
        //  var _ = unsafe.Slice(&x, uint64(1) << 63)
-       _InvalidUnsafeSlice
+       InvalidUnsafeSlice
 
        // All codes below were added in Go 1.18.
 
-       // _UnsupportedFeature occurs when a language feature is used that is not
+       // UnsupportedFeature occurs when a language feature is used that is not
        // supported at this Go version.
-       _UnsupportedFeature
+       UnsupportedFeature
 
-       // _NotAGenericType occurs when a non-generic type is used where a generic
+       // NotAGenericType occurs when a non-generic type is used where a generic
        // type is expected: in type or function instantiation.
        //
        // Example:
        //  type T int
        //
        //  var _ T[int]
-       _NotAGenericType
+       NotAGenericType
 
-       // _WrongTypeArgCount occurs when a type or function is instantiated with an
+       // WrongTypeArgCount occurs when a type or function is instantiated with an
        // incorrent number of type arguments, including when a generic type or
        // function is used without instantiation.
        //
@@ -1332,9 +1332,9 @@ const (
        //  func f[T any]() {}
        //
        //  var x = f
-       _WrongTypeArgCount
+       WrongTypeArgCount
 
-       // _CannotInferTypeArgs occurs when type or function type argument inference
+       // CannotInferTypeArgs occurs when type or function type argument inference
        // fails to infer all type arguments.
        //
        // Example:
@@ -1343,48 +1343,48 @@ const (
        //  func _() {
        //      f()
        //  }
-       _CannotInferTypeArgs
+       CannotInferTypeArgs
 
-       // _InvalidTypeArg occurs when a type argument does not satisfy its
+       // InvalidTypeArg occurs when a type argument does not satisfy its
        // corresponding type parameter constraints.
        //
        // Example:
        //  type T[P ~int] struct{}
        //
        //  var _ T[string]
-       _InvalidTypeArg // arguments? InferenceFailed
+       InvalidTypeArg // arguments? InferenceFailed
 
-       // _InvalidInstanceCycle occurs when an invalid cycle is detected
+       // InvalidInstanceCycle occurs when an invalid cycle is detected
        // within the instantiation graph.
        //
        // Example:
        //  func f[T any]() { f[*T]() }
-       _InvalidInstanceCycle
+       InvalidInstanceCycle
 
-       // _InvalidUnion occurs when an embedded union or approximation element is
+       // InvalidUnion occurs when an embedded union or approximation element is
        // not valid.
        //
        // Example:
        //  type _ interface {
        //      ~int | interface{ m() }
        //  }
-       _InvalidUnion
+       InvalidUnion
 
-       // _MisplacedConstraintIface occurs when a constraint-type interface is used
+       // MisplacedConstraintIface occurs when a constraint-type interface is used
        // outside of constraint position.
        //
        // Example:
        //   type I interface { ~int }
        //
        //   var _ I
-       _MisplacedConstraintIface
+       MisplacedConstraintIface
 
-       // _InvalidMethodTypeParams occurs when methods have type parameters.
+       // InvalidMethodTypeParams occurs when methods have type parameters.
        //
        // It cannot be encountered with an AST parsed using go/parser.
-       _InvalidMethodTypeParams
+       InvalidMethodTypeParams
 
-       // _MisplacedTypeParam occurs when a type parameter is used in a place where
+       // MisplacedTypeParam occurs when a type parameter is used in a place where
        // it is not permitted.
        //
        // Example:
@@ -1392,9 +1392,9 @@ const (
        //
        // Example:
        //  type T[P any] struct{ *P }
-       _MisplacedTypeParam
+       MisplacedTypeParam
 
-       // _InvalidUnsafeSliceData occurs when unsafe.SliceData is called with
+       // InvalidUnsafeSliceData occurs when unsafe.SliceData is called with
        // an argument that is not of slice type. It also occurs if it is used
        // in a package compiled for a language version before go1.20.
        //
@@ -1403,9 +1403,9 @@ const (
        //
        //  var x int
        //  var _ = unsafe.SliceData(x)
-       _InvalidUnsafeSliceData
+       InvalidUnsafeSliceData
 
-       // _InvalidUnsafeString occurs when unsafe.String is called with
+       // InvalidUnsafeString occurs when unsafe.String is called with
        // a length argument that is not of integer type, negative, or
        // out of bounds. It also occurs if it is used in a package
        // compiled for a language version before go1.20.
@@ -1415,9 +1415,9 @@ const (
        //
        //  var b [10]byte
        //  var _ = unsafe.String(&b[0], -1)
-       _InvalidUnsafeString
+       InvalidUnsafeString
 
-       // _InvalidUnsafeStringData occurs if it is used in a package
+       // InvalidUnsafeStringData occurs if it is used in a package
        // compiled for a language version before go1.20.
        _ // not used anymore
 )
index 37a4aa6ae8c51d046028cdccd30f07ab1bc76036..3bf466aec4d0d6a99ae80fd4b11aaced99410e07 100644 (file)
@@ -69,7 +69,7 @@ func walkCodes(t *testing.T, f func(string, int, *ast.ValueSpec)) {
                                continue
                        }
                        obj := info.ObjectOf(spec.Names[0])
-                       if named, ok := obj.Type().(*Named); ok && named.Obj().Name() == "errorCode" {
+                       if named, ok := obj.Type().(*Named); ok && named.Obj().Name() == "Code" {
                                if len(spec.Names) != 1 {
                                        t.Fatalf("bad Code declaration for %q: got %d names, want exactly 1", spec.Names[0].Name, len(spec.Names))
                                }
@@ -154,13 +154,8 @@ func TestErrorCodeStyle(t *testing.T) {
                if len(name) > len(longestName) {
                        longestName = name
                }
-               if token.IsExported(name) {
-                       // This is an experimental API, and errorCode values should not be
-                       // exported.
-                       t.Errorf("%q is exported", name)
-               }
-               if name[0] != '_' || !token.IsExported(name[1:]) {
-                       t.Errorf("%q should start with _, followed by an exported identifier", name)
+               if !token.IsExported(name) {
+                       t.Errorf("%q is not exported", name)
                }
                lower := strings.ToLower(name)
                for _, bad := range forbiddenInIdent {