.gitignore added
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / golang.org / x / tools@v0.1.0 / internal / typesinternal / errorcode.go
1 // Copyright 2020 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 package typesinternal
6
7 //go:generate stringer -type=ErrorCode
8
9 type ErrorCode int
10
11 // This file defines the error codes that can be produced during type-checking.
12 // Collectively, these codes provide an identifier that may be used to
13 // implement special handling for certain types of errors.
14 //
15 // Error codes should be fine-grained enough that the exact nature of the error
16 // can be easily determined, but coarse enough that they are not an
17 // implementation detail of the type checking algorithm. As a rule-of-thumb,
18 // errors should be considered equivalent if there is a theoretical refactoring
19 // of the type checker in which they are emitted in exactly one place. For
20 // example, the type checker emits different error messages for "too many
21 // arguments" and "too few arguments", but one can imagine an alternative type
22 // checker where this check instead just emits a single "wrong number of
23 // arguments", so these errors should have the same code.
24 //
25 // Error code names should be as brief as possible while retaining accuracy and
26 // distinctiveness. In most cases names should start with an adjective
27 // describing the nature of the error (e.g. "invalid", "unused", "misplaced"),
28 // and end with a noun identifying the relevant language object. For example,
29 // "DuplicateDecl" or "InvalidSliceExpr". For brevity, naming follows the
30 // convention that "bad" implies a problem with syntax, and "invalid" implies a
31 // problem with types.
32
33 const (
34         _ ErrorCode = iota
35
36         // Test is reserved for errors that only apply while in self-test mode.
37         Test
38
39         /* package names */
40
41         // BlankPkgName occurs when a package name is the blank identifier "_".
42         //
43         // Per the spec:
44         //  "The PackageName must not be the blank identifier."
45         BlankPkgName
46
47         // MismatchedPkgName occurs when a file's package name doesn't match the
48         // package name already established by other files.
49         MismatchedPkgName
50
51         // InvalidPkgUse occurs when a package identifier is used outside of a
52         // selector expression.
53         //
54         // Example:
55         //  import "fmt"
56         //
57         //  var _ = fmt
58         InvalidPkgUse
59
60         /* imports */
61
62         // BadImportPath occurs when an import path is not valid.
63         BadImportPath
64
65         // BrokenImport occurs when importing a package fails.
66         //
67         // Example:
68         //  import "amissingpackage"
69         BrokenImport
70
71         // ImportCRenamed occurs when the special import "C" is renamed. "C" is a
72         // pseudo-package, and must not be renamed.
73         //
74         // Example:
75         //  import _ "C"
76         ImportCRenamed
77
78         // UnusedImport occurs when an import is unused.
79         //
80         // Example:
81         //  import "fmt"
82         //
83         //  func main() {}
84         UnusedImport
85
86         /* initialization */
87
88         // InvalidInitCycle occurs when an invalid cycle is detected within the
89         // initialization graph.
90         //
91         // Example:
92         //  var x int = f()
93         //
94         //  func f() int { return x }
95         InvalidInitCycle
96
97         /* decls */
98
99         // DuplicateDecl occurs when an identifier is declared multiple times.
100         //
101         // Example:
102         //  var x = 1
103         //  var x = 2
104         DuplicateDecl
105
106         // InvalidDeclCycle occurs when a declaration cycle is not valid.
107         //
108         // Example:
109         //  import "unsafe"
110         //
111         //  type T struct {
112         //      a [n]int
113         //  }
114         //
115         //  var n = unsafe.Sizeof(T{})
116         InvalidDeclCycle
117
118         // InvalidTypeCycle occurs when a cycle in type definitions results in a
119         // type that is not well-defined.
120         //
121         // Example:
122         //  import "unsafe"
123         //
124         //  type T [unsafe.Sizeof(T{})]int
125         InvalidTypeCycle
126
127         /* decls > const */
128
129         // InvalidConstInit occurs when a const declaration has a non-constant
130         // initializer.
131         //
132         // Example:
133         //  var x int
134         //  const _ = x
135         InvalidConstInit
136
137         // InvalidConstVal occurs when a const value cannot be converted to its
138         // target type.
139         //
140         // TODO(findleyr): this error code and example are not very clear. Consider
141         // removing it.
142         //
143         // Example:
144         //  const _ = 1 << "hello"
145         InvalidConstVal
146
147         // InvalidConstType occurs when the underlying type in a const declaration
148         // is not a valid constant type.
149         //
150         // Example:
151         //  const c *int = 4
152         InvalidConstType
153
154         /* decls > var (+ other variable assignment codes) */
155
156         // UntypedNil occurs when the predeclared (untyped) value nil is used to
157         // initialize a variable declared without an explicit type.
158         //
159         // Example:
160         //  var x = nil
161         UntypedNil
162
163         // WrongAssignCount occurs when the number of values on the right-hand side
164         // of an assignment or or initialization expression does not match the number
165         // of variables on the left-hand side.
166         //
167         // Example:
168         //  var x = 1, 2
169         WrongAssignCount
170
171         // UnassignableOperand occurs when the left-hand side of an assignment is
172         // not assignable.
173         //
174         // Example:
175         //  func f() {
176         //      const c = 1
177         //      c = 2
178         //  }
179         UnassignableOperand
180
181         // NoNewVar occurs when a short variable declaration (':=') does not declare
182         // new variables.
183         //
184         // Example:
185         //  func f() {
186         //      x := 1
187         //      x := 2
188         //  }
189         NoNewVar
190
191         // MultiValAssignOp occurs when an assignment operation (+=, *=, etc) does
192         // not have single-valued left-hand or right-hand side.
193         //
194         // Per the spec:
195         //  "In assignment operations, both the left- and right-hand expression lists
196         //  must contain exactly one single-valued expression"
197         //
198         // Example:
199         //  func f() int {
200         //      x, y := 1, 2
201         //      x, y += 1
202         //      return x + y
203         //  }
204         MultiValAssignOp
205
206         // InvalidIfaceAssign occurs when a value of type T is used as an
207         // interface, but T does not implement a method of the expected interface.
208         //
209         // Example:
210         //  type I interface {
211         //      f()
212         //  }
213         //
214         //  type T int
215         //
216         //  var x I = T(1)
217         InvalidIfaceAssign
218
219         // InvalidChanAssign occurs when a chan assignment is invalid.
220         //
221         // Per the spec, a value x is assignable to a channel type T if:
222         //  "x is a bidirectional channel value, T is a channel type, x's type V and
223         //  T have identical element types, and at least one of V or T is not a
224         //  defined type."
225         //
226         // Example:
227         //  type T1 chan int
228         //  type T2 chan int
229         //
230         //  var x T1
231         //  // Invalid assignment because both types are named
232         //  var _ T2 = x
233         InvalidChanAssign
234
235         // IncompatibleAssign occurs when the type of the right-hand side expression
236         // in an assignment cannot be assigned to the type of the variable being
237         // assigned.
238         //
239         // Example:
240         //  var x []int
241         //  var _ int = x
242         IncompatibleAssign
243
244         // UnaddressableFieldAssign occurs when trying to assign to a struct field
245         // in a map value.
246         //
247         // Example:
248         //  func f() {
249         //      m := make(map[string]struct{i int})
250         //      m["foo"].i = 42
251         //  }
252         UnaddressableFieldAssign
253
254         /* decls > type (+ other type expression codes) */
255
256         // NotAType occurs when the identifier used as the underlying type in a type
257         // declaration or the right-hand side of a type alias does not denote a type.
258         //
259         // Example:
260         //  var S = 2
261         //
262         //  type T S
263         NotAType
264
265         // InvalidArrayLen occurs when an array length is not a constant value.
266         //
267         // Example:
268         //  var n = 3
269         //  var _ = [n]int{}
270         InvalidArrayLen
271
272         // BlankIfaceMethod occurs when a method name is '_'.
273         //
274         // Per the spec:
275         //  "The name of each explicitly specified method must be unique and not
276         //  blank."
277         //
278         // Example:
279         //  type T interface {
280         //      _(int)
281         //  }
282         BlankIfaceMethod
283
284         // IncomparableMapKey occurs when a map key type does not support the == and
285         // != operators.
286         //
287         // Per the spec:
288         //  "The comparison operators == and != must be fully defined for operands of
289         //  the key type; thus the key type must not be a function, map, or slice."
290         //
291         // Example:
292         //  var x map[T]int
293         //
294         //  type T []int
295         IncomparableMapKey
296
297         // InvalidIfaceEmbed occurs when a non-interface type is embedded in an
298         // interface.
299         //
300         // Example:
301         //  type T struct {}
302         //
303         //  func (T) m()
304         //
305         //  type I interface {
306         //      T
307         //  }
308         InvalidIfaceEmbed
309
310         // InvalidPtrEmbed occurs when an embedded field is of the pointer form *T,
311         // and T itself is itself a pointer, an unsafe.Pointer, or an interface.
312         //
313         // Per the spec:
314         //  "An embedded field must be specified as a type name T or as a pointer to
315         //  a non-interface type name *T, and T itself may not be a pointer type."
316         //
317         // Example:
318         //  type T *int
319         //
320         //  type S struct {
321         //      *T
322         //  }
323         InvalidPtrEmbed
324
325         /* decls > func and method */
326
327         // BadRecv occurs when a method declaration does not have exactly one
328         // receiver parameter.
329         //
330         // Example:
331         //  func () _() {}
332         BadRecv
333
334         // InvalidRecv occurs when a receiver type expression is not of the form T
335         // or *T, or T is a pointer type.
336         //
337         // Example:
338         //  type T struct {}
339         //
340         //  func (**T) m() {}
341         InvalidRecv
342
343         // DuplicateFieldAndMethod occurs when an identifier appears as both a field
344         // and method name.
345         //
346         // Example:
347         //  type T struct {
348         //      m int
349         //  }
350         //
351         //  func (T) m() {}
352         DuplicateFieldAndMethod
353
354         // DuplicateMethod occurs when two methods on the same receiver type have
355         // the same name.
356         //
357         // Example:
358         //  type T struct {}
359         //  func (T) m() {}
360         //  func (T) m(i int) int { return i }
361         DuplicateMethod
362
363         /* decls > special */
364
365         // InvalidBlank occurs when a blank identifier is used as a value or type.
366         //
367         // Per the spec:
368         //  "The blank identifier may appear as an operand only on the left-hand side
369         //  of an assignment."
370         //
371         // Example:
372         //  var x = _
373         InvalidBlank
374
375         // InvalidIota occurs when the predeclared identifier iota is used outside
376         // of a constant declaration.
377         //
378         // Example:
379         //  var x = iota
380         InvalidIota
381
382         // MissingInitBody occurs when an init function is missing its body.
383         //
384         // Example:
385         //  func init()
386         MissingInitBody
387
388         // InvalidInitSig occurs when an init function declares parameters or
389         // results.
390         //
391         // Example:
392         //  func init() int { return 1 }
393         InvalidInitSig
394
395         // InvalidInitDecl occurs when init is declared as anything other than a
396         // function.
397         //
398         // Example:
399         //  var init = 1
400         InvalidInitDecl
401
402         // InvalidMainDecl occurs when main is declared as anything other than a
403         // function, in a main package.
404         InvalidMainDecl
405
406         /* exprs */
407
408         // TooManyValues occurs when a function returns too many values for the
409         // expression context in which it is used.
410         //
411         // Example:
412         //  func ReturnTwo() (int, int) {
413         //      return 1, 2
414         //  }
415         //
416         //  var x = ReturnTwo()
417         TooManyValues
418
419         // NotAnExpr occurs when a type expression is used where a value expression
420         // is expected.
421         //
422         // Example:
423         //  type T struct {}
424         //
425         //  func f() {
426         //      T
427         //  }
428         NotAnExpr
429
430         /* exprs > const */
431
432         // TruncatedFloat occurs when a float constant is truncated to an integer
433         // value.
434         //
435         // Example:
436         //  var _ int = 98.6
437         TruncatedFloat
438
439         // NumericOverflow occurs when a numeric constant overflows its target type.
440         //
441         // Example:
442         //  var x int8 = 1000
443         NumericOverflow
444
445         /* exprs > operation */
446
447         // UndefinedOp occurs when an operator is not defined for the type(s) used
448         // in an operation.
449         //
450         // Example:
451         //  var c = "a" - "b"
452         UndefinedOp
453
454         // MismatchedTypes occurs when operand types are incompatible in a binary
455         // operation.
456         //
457         // Example:
458         //  var a = "hello"
459         //  var b = 1
460         //  var c = a - b
461         MismatchedTypes
462
463         // DivByZero occurs when a division operation is provable at compile
464         // time to be a division by zero.
465         //
466         // Example:
467         //  const divisor = 0
468         //  var x int = 1/divisor
469         DivByZero
470
471         // NonNumericIncDec occurs when an increment or decrement operator is
472         // applied to a non-numeric value.
473         //
474         // Example:
475         //  func f() {
476         //      var c = "c"
477         //      c++
478         //  }
479         NonNumericIncDec
480
481         /* exprs > ptr */
482
483         // UnaddressableOperand occurs when the & operator is applied to an
484         // unaddressable expression.
485         //
486         // Example:
487         //  var x = &1
488         UnaddressableOperand
489
490         // InvalidIndirection occurs when a non-pointer value is indirected via the
491         // '*' operator.
492         //
493         // Example:
494         //  var x int
495         //  var y = *x
496         InvalidIndirection
497
498         /* exprs > [] */
499
500         // NonIndexableOperand occurs when an index operation is applied to a value
501         // that cannot be indexed.
502         //
503         // Example:
504         //  var x = 1
505         //  var y = x[1]
506         NonIndexableOperand
507
508         // InvalidIndex occurs when an index argument is not of integer type,
509         // negative, or out-of-bounds.
510         //
511         // Example:
512         //  var s = [...]int{1,2,3}
513         //  var x = s[5]
514         //
515         // Example:
516         //  var s = []int{1,2,3}
517         //  var _ = s[-1]
518         //
519         // Example:
520         //  var s = []int{1,2,3}
521         //  var i string
522         //  var _ = s[i]
523         InvalidIndex
524
525         // SwappedSliceIndices occurs when constant indices in a slice expression
526         // are decreasing in value.
527         //
528         // Example:
529         //  var _ = []int{1,2,3}[2:1]
530         SwappedSliceIndices
531
532         /* operators > slice */
533
534         // NonSliceableOperand occurs when a slice operation is applied to a value
535         // whose type is not sliceable, or is unaddressable.
536         //
537         // Example:
538         //  var x = [...]int{1, 2, 3}[:1]
539         //
540         // Example:
541         //  var x = 1
542         //  var y = 1[:1]
543         NonSliceableOperand
544
545         // InvalidSliceExpr occurs when a three-index slice expression (a[x:y:z]) is
546         // applied to a string.
547         //
548         // Example:
549         //  var s = "hello"
550         //  var x = s[1:2:3]
551         InvalidSliceExpr
552
553         /* exprs > shift */
554
555         // InvalidShiftCount occurs when the right-hand side of a shift operation is
556         // either non-integer, negative, or too large.
557         //
558         // Example:
559         //  var (
560         //      x string
561         //      y int = 1 << x
562         //  )
563         InvalidShiftCount
564
565         // InvalidShiftOperand occurs when the shifted operand is not an integer.
566         //
567         // Example:
568         //  var s = "hello"
569         //  var x = s << 2
570         InvalidShiftOperand
571
572         /* exprs > chan */
573
574         // InvalidReceive occurs when there is a channel receive from a value that
575         // is either not a channel, or is a send-only channel.
576         //
577         // Example:
578         //  func f() {
579         //      var x = 1
580         //      <-x
581         //  }
582         InvalidReceive
583
584         // InvalidSend occurs when there is a channel send to a value that is not a
585         // channel, or is a receive-only channel.
586         //
587         // Example:
588         //  func f() {
589         //      var x = 1
590         //      x <- "hello!"
591         //  }
592         InvalidSend
593
594         /* exprs > literal */
595
596         // DuplicateLitKey occurs when an index is duplicated in a slice, array, or
597         // map literal.
598         //
599         // Example:
600         //  var _ = []int{0:1, 0:2}
601         //
602         // Example:
603         //  var _ = map[string]int{"a": 1, "a": 2}
604         DuplicateLitKey
605
606         // MissingLitKey occurs when a map literal is missing a key expression.
607         //
608         // Example:
609         //  var _ = map[string]int{1}
610         MissingLitKey
611
612         // InvalidLitIndex occurs when the key in a key-value element of a slice or
613         // array literal is not an integer constant.
614         //
615         // Example:
616         //  var i = 0
617         //  var x = []string{i: "world"}
618         InvalidLitIndex
619
620         // OversizeArrayLit occurs when an array literal exceeds its length.
621         //
622         // Example:
623         //  var _ = [2]int{1,2,3}
624         OversizeArrayLit
625
626         // MixedStructLit occurs when a struct literal contains a mix of positional
627         // and named elements.
628         //
629         // Example:
630         //  var _ = struct{i, j int}{i: 1, 2}
631         MixedStructLit
632
633         // InvalidStructLit occurs when a positional struct literal has an incorrect
634         // number of values.
635         //
636         // Example:
637         //  var _ = struct{i, j int}{1,2,3}
638         InvalidStructLit
639
640         // MissingLitField occurs when a struct literal refers to a field that does
641         // not exist on the struct type.
642         //
643         // Example:
644         //  var _ = struct{i int}{j: 2}
645         MissingLitField
646
647         // DuplicateLitField occurs when a struct literal contains duplicated
648         // fields.
649         //
650         // Example:
651         //  var _ = struct{i int}{i: 1, i: 2}
652         DuplicateLitField
653
654         // UnexportedLitField occurs when a positional struct literal implicitly
655         // assigns an unexported field of an imported type.
656         UnexportedLitField
657
658         // InvalidLitField occurs when a field name is not a valid identifier.
659         //
660         // Example:
661         //  var _ = struct{i int}{1: 1}
662         InvalidLitField
663
664         // UntypedLit occurs when a composite literal omits a required type
665         // identifier.
666         //
667         // Example:
668         //  type outer struct{
669         //      inner struct { i int }
670         //  }
671         //
672         //  var _ = outer{inner: {1}}
673         UntypedLit
674
675         // InvalidLit occurs when a composite literal expression does not match its
676         // type.
677         //
678         // Example:
679         //  type P *struct{
680         //      x int
681         //  }
682         //  var _ = P {}
683         InvalidLit
684
685         /* exprs > selector */
686
687         // AmbiguousSelector occurs when a selector is ambiguous.
688         //
689         // Example:
690         //  type E1 struct { i int }
691         //  type E2 struct { i int }
692         //  type T struct { E1; E2 }
693         //
694         //  var x T
695         //  var _ = x.i
696         AmbiguousSelector
697
698         // UndeclaredImportedName occurs when a package-qualified identifier is
699         // undeclared by the imported package.
700         //
701         // Example:
702         //  import "go/types"
703         //
704         //  var _ = types.NotAnActualIdentifier
705         UndeclaredImportedName
706
707         // UnexportedName occurs when a selector refers to an unexported identifier
708         // of an imported package.
709         //
710         // Example:
711         //  import "reflect"
712         //
713         //  type _ reflect.flag
714         UnexportedName
715
716         // UndeclaredName occurs when an identifier is not declared in the current
717         // scope.
718         //
719         // Example:
720         //  var x T
721         UndeclaredName
722
723         // MissingFieldOrMethod occurs when a selector references a field or method
724         // that does not exist.
725         //
726         // Example:
727         //  type T struct {}
728         //
729         //  var x = T{}.f
730         MissingFieldOrMethod
731
732         /* exprs > ... */
733
734         // BadDotDotDotSyntax occurs when a "..." occurs in a context where it is
735         // not valid.
736         //
737         // Example:
738         //  var _ = map[int][...]int{0: {}}
739         BadDotDotDotSyntax
740
741         // NonVariadicDotDotDot occurs when a "..." is used on the final argument to
742         // a non-variadic function.
743         //
744         // Example:
745         //  func printArgs(s []string) {
746         //      for _, a := range s {
747         //              println(a)
748         //      }
749         //  }
750         //
751         //  func f() {
752         //      s := []string{"a", "b", "c"}
753         //      printArgs(s...)
754         //  }
755         NonVariadicDotDotDot
756
757         // MisplacedDotDotDot occurs when a "..." is used somewhere other than the
758         // final argument to a function call.
759         //
760         // Example:
761         //  func printArgs(args ...int) {
762         //      for _, a := range args {
763         //              println(a)
764         //      }
765         //  }
766         //
767         //  func f() {
768         //      a := []int{1,2,3}
769         //      printArgs(0, a...)
770         //  }
771         MisplacedDotDotDot
772
773         // InvalidDotDotDotOperand occurs when a "..." operator is applied to a
774         // single-valued operand.
775         //
776         // Example:
777         //  func printArgs(args ...int) {
778         //      for _, a := range args {
779         //              println(a)
780         //      }
781         //  }
782         //
783         //  func f() {
784         //      a := 1
785         //      printArgs(a...)
786         //  }
787         //
788         // Example:
789         //  func args() (int, int) {
790         //      return 1, 2
791         //  }
792         //
793         //  func printArgs(args ...int) {
794         //      for _, a := range args {
795         //              println(a)
796         //      }
797         //  }
798         //
799         //  func g() {
800         //      printArgs(args()...)
801         //  }
802         InvalidDotDotDotOperand
803
804         // InvalidDotDotDot occurs when a "..." is used in a non-variadic built-in
805         // function.
806         //
807         // Example:
808         //  var s = []int{1, 2, 3}
809         //  var l = len(s...)
810         InvalidDotDotDot
811
812         /* exprs > built-in */
813
814         // UncalledBuiltin occurs when a built-in function is used as a
815         // function-valued expression, instead of being called.
816         //
817         // Per the spec:
818         //  "The built-in functions do not have standard Go types, so they can only
819         //  appear in call expressions; they cannot be used as function values."
820         //
821         // Example:
822         //  var _ = copy
823         UncalledBuiltin
824
825         // InvalidAppend occurs when append is called with a first argument that is
826         // not a slice.
827         //
828         // Example:
829         //  var _ = append(1, 2)
830         InvalidAppend
831
832         // InvalidCap occurs when an argument to the cap built-in function is not of
833         // supported type.
834         //
835         // See https://golang.org/ref/spec#Lengthand_capacity for information on
836         // which underlying types are supported as arguments to cap and len.
837         //
838         // Example:
839         //  var s = 2
840         //  var x = cap(s)
841         InvalidCap
842
843         // InvalidClose occurs when close(...) is called with an argument that is
844         // not of channel type, or that is a receive-only channel.
845         //
846         // Example:
847         //  func f() {
848         //      var x int
849         //      close(x)
850         //  }
851         InvalidClose
852
853         // InvalidCopy occurs when the arguments are not of slice type or do not
854         // have compatible type.
855         //
856         // See https://golang.org/ref/spec#Appendingand_copying_slices for more
857         // information on the type requirements for the copy built-in.
858         //
859         // Example:
860         //  func f() {
861         //      var x []int
862         //      y := []int64{1,2,3}
863         //      copy(x, y)
864         //  }
865         InvalidCopy
866
867         // InvalidComplex occurs when the complex built-in function is called with
868         // arguments with incompatible types.
869         //
870         // Example:
871         //  var _ = complex(float32(1), float64(2))
872         InvalidComplex
873
874         // InvalidDelete occurs when the delete built-in function is called with a
875         // first argument that is not a map.
876         //
877         // Example:
878         //  func f() {
879         //      m := "hello"
880         //      delete(m, "e")
881         //  }
882         InvalidDelete
883
884         // InvalidImag occurs when the imag built-in function is called with an
885         // argument that does not have complex type.
886         //
887         // Example:
888         //  var _ = imag(int(1))
889         InvalidImag
890
891         // InvalidLen occurs when an argument to the len built-in function is not of
892         // supported type.
893         //
894         // See https://golang.org/ref/spec#Lengthand_capacity for information on
895         // which underlying types are supported as arguments to cap and len.
896         //
897         // Example:
898         //  var s = 2
899         //  var x = len(s)
900         InvalidLen
901
902         // SwappedMakeArgs occurs when make is called with three arguments, and its
903         // length argument is larger than its capacity argument.
904         //
905         // Example:
906         //  var x = make([]int, 3, 2)
907         SwappedMakeArgs
908
909         // InvalidMake occurs when make is called with an unsupported type argument.
910         //
911         // See https://golang.org/ref/spec#Makingslices_maps_and_channels for
912         // information on the types that may be created using make.
913         //
914         // Example:
915         //  var x = make(int)
916         InvalidMake
917
918         // InvalidReal occurs when the real built-in function is called with an
919         // argument that does not have complex type.
920         //
921         // Example:
922         //  var _ = real(int(1))
923         InvalidReal
924
925         /* exprs > assertion */
926
927         // InvalidAssert occurs when a type assertion is applied to a
928         // value that is not of interface type.
929         //
930         // Example:
931         //  var x = 1
932         //  var _ = x.(float64)
933         InvalidAssert
934
935         // ImpossibleAssert occurs for a type assertion x.(T) when the value x of
936         // interface cannot have dynamic type T, due to a missing or mismatching
937         // method on T.
938         //
939         // Example:
940         //  type T int
941         //
942         //  func (t *T) m() int { return int(*t) }
943         //
944         //  type I interface { m() int }
945         //
946         //  var x I
947         //  var _ = x.(T)
948         ImpossibleAssert
949
950         /* exprs > conversion */
951
952         // InvalidConversion occurs when the argument type cannot be converted to the
953         // target.
954         //
955         // See https://golang.org/ref/spec#Conversions for the rules of
956         // convertibility.
957         //
958         // Example:
959         //  var x float64
960         //  var _ = string(x)
961         InvalidConversion
962
963         // InvalidUntypedConversion occurs when an there is no valid implicit
964         // conversion from an untyped value satisfying the type constraints of the
965         // context in which it is used.
966         //
967         // Example:
968         //  var _ = 1 + ""
969         InvalidUntypedConversion
970
971         /* offsetof */
972
973         // BadOffsetofSyntax occurs when unsafe.Offsetof is called with an argument
974         // that is not a selector expression.
975         //
976         // Example:
977         //  import "unsafe"
978         //
979         //  var x int
980         //  var _ = unsafe.Offsetof(x)
981         BadOffsetofSyntax
982
983         // InvalidOffsetof occurs when unsafe.Offsetof is called with a method
984         // selector, rather than a field selector, or when the field is embedded via
985         // a pointer.
986         //
987         // Per the spec:
988         //
989         //  "If f is an embedded field, it must be reachable without pointer
990         //  indirections through fields of the struct. "
991         //
992         // Example:
993         //  import "unsafe"
994         //
995         //  type T struct { f int }
996         //  type S struct { *T }
997         //  var s S
998         //  var _ = unsafe.Offsetof(s.f)
999         //
1000         // Example:
1001         //  import "unsafe"
1002         //
1003         //  type S struct{}
1004         //
1005         //  func (S) m() {}
1006         //
1007         //  var s S
1008         //  var _ = unsafe.Offsetof(s.m)
1009         InvalidOffsetof
1010
1011         /* control flow > scope */
1012
1013         // UnusedExpr occurs when a side-effect free expression is used as a
1014         // statement. Such a statement has no effect.
1015         //
1016         // Example:
1017         //  func f(i int) {
1018         //      i*i
1019         //  }
1020         UnusedExpr
1021
1022         // UnusedVar occurs when a variable is declared but unused.
1023         //
1024         // Example:
1025         //  func f() {
1026         //      x := 1
1027         //  }
1028         UnusedVar
1029
1030         // MissingReturn occurs when a function with results is missing a return
1031         // statement.
1032         //
1033         // Example:
1034         //  func f() int {}
1035         MissingReturn
1036
1037         // WrongResultCount occurs when a return statement returns an incorrect
1038         // number of values.
1039         //
1040         // Example:
1041         //  func ReturnOne() int {
1042         //      return 1, 2
1043         //  }
1044         WrongResultCount
1045
1046         // OutOfScopeResult occurs when the name of a value implicitly returned by
1047         // an empty return statement is shadowed in a nested scope.
1048         //
1049         // Example:
1050         //  func factor(n int) (i int) {
1051         //      for i := 2; i < n; i++ {
1052         //              if n%i == 0 {
1053         //                      return
1054         //              }
1055         //      }
1056         //      return 0
1057         //  }
1058         OutOfScopeResult
1059
1060         /* control flow > if */
1061
1062         // InvalidCond occurs when an if condition is not a boolean expression.
1063         //
1064         // Example:
1065         //  func checkReturn(i int) {
1066         //      if i {
1067         //              panic("non-zero return")
1068         //      }
1069         //  }
1070         InvalidCond
1071
1072         /* control flow > for */
1073
1074         // InvalidPostDecl occurs when there is a declaration in a for-loop post
1075         // statement.
1076         //
1077         // Example:
1078         //  func f() {
1079         //      for i := 0; i < 10; j := 0 {}
1080         //  }
1081         InvalidPostDecl
1082
1083         // InvalidChanRange occurs when a send-only channel used in a range
1084         // expression.
1085         //
1086         // Example:
1087         //  func sum(c chan<- int) {
1088         //      s := 0
1089         //      for i := range c {
1090         //              s += i
1091         //      }
1092         //  }
1093         InvalidChanRange
1094
1095         // InvalidIterVar occurs when two iteration variables are used while ranging
1096         // over a channel.
1097         //
1098         // Example:
1099         //  func f(c chan int) {
1100         //      for k, v := range c {
1101         //              println(k, v)
1102         //      }
1103         //  }
1104         InvalidIterVar
1105
1106         // InvalidRangeExpr occurs when the type of a range expression is not array,
1107         // slice, string, map, or channel.
1108         //
1109         // Example:
1110         //  func f(i int) {
1111         //      for j := range i {
1112         //              println(j)
1113         //      }
1114         //  }
1115         InvalidRangeExpr
1116
1117         /* control flow > switch */
1118
1119         // MisplacedBreak occurs when a break statement is not within a for, switch,
1120         // or select statement of the innermost function definition.
1121         //
1122         // Example:
1123         //  func f() {
1124         //      break
1125         //  }
1126         MisplacedBreak
1127
1128         // MisplacedContinue occurs when a continue statement is not within a for
1129         // loop of the innermost function definition.
1130         //
1131         // Example:
1132         //  func sumeven(n int) int {
1133         //      proceed := func() {
1134         //              continue
1135         //      }
1136         //      sum := 0
1137         //      for i := 1; i <= n; i++ {
1138         //              if i % 2 != 0 {
1139         //                      proceed()
1140         //              }
1141         //              sum += i
1142         //      }
1143         //      return sum
1144         //  }
1145         MisplacedContinue
1146
1147         // MisplacedFallthrough occurs when a fallthrough statement is not within an
1148         // expression switch.
1149         //
1150         // Example:
1151         //  func typename(i interface{}) string {
1152         //      switch i.(type) {
1153         //      case int64:
1154         //              fallthrough
1155         //      case int:
1156         //              return "int"
1157         //      }
1158         //      return "unsupported"
1159         //  }
1160         MisplacedFallthrough
1161
1162         // DuplicateCase occurs when a type or expression switch has duplicate
1163         // cases.
1164         //
1165         // Example:
1166         //  func printInt(i int) {
1167         //      switch i {
1168         //      case 1:
1169         //              println("one")
1170         //      case 1:
1171         //              println("One")
1172         //      }
1173         //  }
1174         DuplicateCase
1175
1176         // DuplicateDefault occurs when a type or expression switch has multiple
1177         // default clauses.
1178         //
1179         // Example:
1180         //  func printInt(i int) {
1181         //      switch i {
1182         //      case 1:
1183         //              println("one")
1184         //      default:
1185         //              println("One")
1186         //      default:
1187         //              println("1")
1188         //      }
1189         //  }
1190         DuplicateDefault
1191
1192         // BadTypeKeyword occurs when a .(type) expression is used anywhere other
1193         // than a type switch.
1194         //
1195         // Example:
1196         //  type I interface {
1197         //      m()
1198         //  }
1199         //  var t I
1200         //  var _ = t.(type)
1201         BadTypeKeyword
1202
1203         // InvalidTypeSwitch occurs when .(type) is used on an expression that is
1204         // not of interface type.
1205         //
1206         // Example:
1207         //  func f(i int) {
1208         //      switch x := i.(type) {}
1209         //  }
1210         InvalidTypeSwitch
1211
1212         /* control flow > select */
1213
1214         // InvalidSelectCase occurs when a select case is not a channel send or
1215         // receive.
1216         //
1217         // Example:
1218         //  func checkChan(c <-chan int) bool {
1219         //      select {
1220         //      case c:
1221         //              return true
1222         //      default:
1223         //              return false
1224         //      }
1225         //  }
1226         InvalidSelectCase
1227
1228         /* control flow > labels and jumps */
1229
1230         // UndeclaredLabel occurs when an undeclared label is jumped to.
1231         //
1232         // Example:
1233         //  func f() {
1234         //      goto L
1235         //  }
1236         UndeclaredLabel
1237
1238         // DuplicateLabel occurs when a label is declared more than once.
1239         //
1240         // Example:
1241         //  func f() int {
1242         //  L:
1243         //  L:
1244         //      return 1
1245         //  }
1246         DuplicateLabel
1247
1248         // MisplacedLabel occurs when a break or continue label is not on a for,
1249         // switch, or select statement.
1250         //
1251         // Example:
1252         //  func f() {
1253         //  L:
1254         //      a := []int{1,2,3}
1255         //      for _, e := range a {
1256         //              if e > 10 {
1257         //                      break L
1258         //              }
1259         //              println(a)
1260         //      }
1261         //  }
1262         MisplacedLabel
1263
1264         // UnusedLabel occurs when a label is declared but not used.
1265         //
1266         // Example:
1267         //  func f() {
1268         //  L:
1269         //  }
1270         UnusedLabel
1271
1272         // JumpOverDecl occurs when a label jumps over a variable declaration.
1273         //
1274         // Example:
1275         //  func f() int {
1276         //      goto L
1277         //      x := 2
1278         //  L:
1279         //      x++
1280         //      return x
1281         //  }
1282         JumpOverDecl
1283
1284         // JumpIntoBlock occurs when a forward jump goes to a label inside a nested
1285         // block.
1286         //
1287         // Example:
1288         //  func f(x int) {
1289         //      goto L
1290         //      if x > 0 {
1291         //      L:
1292         //              print("inside block")
1293         //      }
1294         // }
1295         JumpIntoBlock
1296
1297         /* control flow > calls */
1298
1299         // InvalidMethodExpr occurs when a pointer method is called but the argument
1300         // is not addressable.
1301         //
1302         // Example:
1303         //  type T struct {}
1304         //
1305         //  func (*T) m() int { return 1 }
1306         //
1307         //  var _ = T.m(T{})
1308         InvalidMethodExpr
1309
1310         // WrongArgCount occurs when too few or too many arguments are passed by a
1311         // function call.
1312         //
1313         // Example:
1314         //  func f(i int) {}
1315         //  var x = f()
1316         WrongArgCount
1317
1318         // InvalidCall occurs when an expression is called that is not of function
1319         // type.
1320         //
1321         // Example:
1322         //  var x = "x"
1323         //  var y = x()
1324         InvalidCall
1325
1326         /* control flow > suspended */
1327
1328         // UnusedResults occurs when a restricted expression-only built-in function
1329         // is suspended via go or defer. Such a suspension discards the results of
1330         // these side-effect free built-in functions, and therefore is ineffectual.
1331         //
1332         // Example:
1333         //  func f(a []int) int {
1334         //      defer len(a)
1335         //      return i
1336         //  }
1337         UnusedResults
1338
1339         // InvalidDefer occurs when a deferred expression is not a function call,
1340         // for example if the expression is a type conversion.
1341         //
1342         // Example:
1343         //  func f(i int) int {
1344         //      defer int32(i)
1345         //      return i
1346         //  }
1347         InvalidDefer
1348
1349         // InvalidGo occurs when a go expression is not a function call, for example
1350         // if the expression is a type conversion.
1351         //
1352         // Example:
1353         //  func f(i int) int {
1354         //      go int32(i)
1355         //      return i
1356         //  }
1357         InvalidGo
1358 )