cue: fix misspells

Change-Id: I067e923857d30d01e674715f0988d396c071a37f
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6661
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cmd/cue/cmd/trim.go b/cmd/cue/cmd/trim.go
index 61ae3ce..9ad5d30 100644
--- a/cmd/cue/cmd/trim.go
+++ b/cmd/cue/cmd/trim.go
@@ -40,7 +40,7 @@
 		Long: `trim removes fields from structs that can be inferred from constraints
 
 A field, struct, or list is removed if it is implied by a constraint, such
-as from an optional field maching a required field, a list type value,
+as from an optional field matching a required field, a list type value,
 a comprehension or any other implied content. It will modify the files in place.
 
 
diff --git a/cue/ast.go b/cue/ast.go
index a317f4a..815865c 100644
--- a/cue/ast.go
+++ b/cue/ast.go
@@ -609,7 +609,7 @@
 
 		// Allow different names to refer to the same field in unification. We
 		// do this by anonymizing the the reference. This then has to be
-		// resolved again when refering to lambdas.
+		// resolved again when referring to lambdas.
 		l, lambda := n2.(*lambdaExpr)
 		if lambda && len(l.params.arcs) == 1 {
 			f = 0
diff --git a/cue/ast/ast.go b/cue/ast/ast.go
index ab8ce36..78117b6 100644
--- a/cue/ast/ast.go
+++ b/cue/ast/ast.go
@@ -490,7 +490,7 @@
 // A field is either a *Field, an *Elipsis, *LetClause, a *CommentGroup, or a
 // Label, optionally followed by a a token.OPTION to indicate the field is
 // optional, optionally followed by a token.ISA to indicate the field is a
-// defintion followed by an expression for the field value.
+// definition followed by an expression for the field value.
 //
 // It will panic if a values not matching these patterns are given. Useful for
 // ASTs generated by code other than the CUE parser.
diff --git a/cue/go.go b/cue/go.go
index c0408e0..ae41b4b 100644
--- a/cue/go.go
+++ b/cue/go.go
@@ -103,7 +103,7 @@
 	switch f.Type.Kind() {
 	case reflect.Ptr, reflect.Map, reflect.Chan, reflect.Interface, reflect.Slice:
 		// Note: it may be confusing to distinguish between an empty slice and
-		// a nil slice. However, it is also surprizing to not be able to specify
+		// a nil slice. However, it is also surprising to not be able to specify
 		// a default value for a slice. So for now we will allow it.
 		isOptional = true
 	}
@@ -135,7 +135,7 @@
 	switch f.Type.Kind() {
 	case reflect.Ptr, reflect.Map, reflect.Chan, reflect.Interface, reflect.Slice:
 		// Note: it may be confusing to distinguish between an empty slice and
-		// a nil slice. However, it is also surprizing to not be able to specify
+		// a nil slice. However, it is also surprising to not be able to specify
 		// a default value for a slice. So for now we will allow it.
 		isOmitEmpty = true
 
diff --git a/cue/testdata/references/labelstop.txtar b/cue/testdata/references/labelstop.txtar
index b936ab0..0899f8f 100644
--- a/cue/testdata/references/labelstop.txtar
+++ b/cue/testdata/references/labelstop.txtar
@@ -1,4 +1,4 @@
-TODO: add maching when bulk optional fields are allowed
+TODO: add matching when bulk optional fields are allowed
 alongside other fields.
 -- in.cue --
 {[X=string]: baz: X}
diff --git a/cue/types.go b/cue/types.go
index 9000165..faf87b7 100644
--- a/cue/types.go
+++ b/cue/types.go
@@ -1453,7 +1453,7 @@
 		}
 	}
 	return newErrValue(v, ctx.mkErr(v.v.v,
-		"defintion %q not found", name))
+		"definition %q not found", name))
 }
 
 var errNotFound = errors.Newf(token.NoPos, "field not found")
@@ -1989,7 +1989,7 @@
 func (x *validator) walk(v Value, opts options) {
 	// TODO(#42): we can get rid of the arbitrary evaluation depth once CUE has
 	// proper structural cycle detection. See Issue #42. Currently errors
-	// occuring at a depth > internal.MaxDepth will not be detected.
+	// occurring at a depth > internal.MaxDepth will not be detected.
 	if x.depth > internal.MaxDepth {
 		return
 	}
diff --git a/cue/types_test.go b/cue/types_test.go
index e124aa9..cea8a14 100644
--- a/cue/types_test.go
+++ b/cue/types_test.go
@@ -890,11 +890,11 @@
 	}, {
 		in:  `_foo: 3`,
 		def: "_foo",
-		out: `_|_(defintion "_foo" not found)`,
+		out: `_|_(definition "_foo" not found)`,
 	}, {
 		in:  `_#foo: 3`,
 		def: "_#foo",
-		out: `_|_(defintion "_#foo" not found)`,
+		out: `_|_(definition "_#foo" not found)`,
 	}}
 
 	for _, tc := range testCases {
diff --git a/encoding/jsonschema/decode.go b/encoding/jsonschema/decode.go
index 30b0dc7..54f8fd6 100644
--- a/encoding/jsonschema/decode.go
+++ b/encoding/jsonschema/decode.go
@@ -564,7 +564,7 @@
 			c := constraintMap[key]
 			if c == nil {
 				if pass == 0 && s.cfg.Strict {
-					// TODO: value is not the correct possition, albeit close. Fix this.
+					// TODO: value is not the correct position, albeit close. Fix this.
 					s.warnf(value.Pos(), "unsupported constraint %q", key)
 				}
 				return
diff --git a/encoding/openapi/build.go b/encoding/openapi/build.go
index 8087fa5..c1453d6 100644
--- a/encoding/openapi/build.go
+++ b/encoding/openapi/build.go
@@ -549,7 +549,7 @@
 	}
 
 	for i, v := range disjuncts {
-		// In OpenAPI schema are open by default. To ensure forward compability,
+		// In OpenAPI schema are open by default. To ensure forward compatibility,
 		// we do not represent closed structs with additionalProperties: false
 		// (this is discouraged and often disallowed by implementions), but
 		// rather enforce this by ensuring uniqueness of the disjuncts.
diff --git a/encoding/protobuf/protobuf.go b/encoding/protobuf/protobuf.go
index 848726d..5ce0505 100644
--- a/encoding/protobuf/protobuf.go
+++ b/encoding/protobuf/protobuf.go
@@ -35,7 +35,7 @@
 //
 // Type Mappings
 //
-// The following type mappings of defintions apply:
+// The following type mappings of definitions apply:
 //
 //   Proto type     CUE type/def     Comments
 //   message        struct           Message fields become CUE fields, whereby
diff --git a/internal/core/adt/doc.go b/internal/core/adt/doc.go
index ba251b5..26c978e 100644
--- a/internal/core/adt/doc.go
+++ b/internal/core/adt/doc.go
@@ -45,7 +45,7 @@
 // it refers. If the copied value itself contains references we can distinguish
 // two different cases. References that refer to values within the copied
 // reference (not regarding selectors) will henceforth point to the copied node.
-// References that point to outside the referened value will keep refering to
+// References that point to outside the referened value will keep referring to
 // their original value.
 //
 //      a: b: {
diff --git a/internal/core/convert/go.go b/internal/core/convert/go.go
index 98f168e..8aeca32 100644
--- a/internal/core/convert/go.go
+++ b/internal/core/convert/go.go
@@ -117,7 +117,7 @@
 	switch f.Type.Kind() {
 	case reflect.Ptr, reflect.Map, reflect.Chan, reflect.Interface, reflect.Slice:
 		// Note: it may be confusing to distinguish between an empty slice and
-		// a nil slice. However, it is also surprizing to not be able to specify
+		// a nil slice. However, it is also surprising to not be able to specify
 		// a default value for a slice. So for now we will allow it.
 		isOptional = true
 	}
@@ -149,7 +149,7 @@
 	switch f.Type.Kind() {
 	case reflect.Ptr, reflect.Map, reflect.Chan, reflect.Interface, reflect.Slice:
 		// Note: it may be confusing to distinguish between an empty slice and
-		// a nil slice. However, it is also surprizing to not be able to specify
+		// a nil slice. However, it is also surprising to not be able to specify
 		// a default value for a slice. So for now we will allow it.
 		isOmitEmpty = true
 
diff --git a/internal/core/eval/closed.go b/internal/core/eval/closed.go
index c909b43..fcfa52a 100644
--- a/internal/core/eval/closed.go
+++ b/internal/core/eval/closed.go
@@ -63,7 +63,7 @@
 //    }
 //
 // At the point of evaluating `a`, the struct is not yet closed. However,
-// descending into `d` will trigger the inclusion of defintions which in turn
+// descending into `d` will trigger the inclusion of definitions which in turn
 // causes the struct to be closed. At this point, it is important to know that
 // `b` originated from an embedding, as otherwise `e` may not be allowed.
 //
@@ -319,7 +319,7 @@
 	return false
 }
 
-// verifyDefintion reports whether f is a valid member for any of the fieldSets
+// verifyDefinition reports whether f is a valid member for any of the fieldSets
 // with the same closeID.
 func (n *acceptor) verifyDefinition(ctx *adt.OpContext, closeID uint32, f adt.Feature) (ok bool) {
 	for _, o := range n.fields {
diff --git a/internal/core/eval/eval.go b/internal/core/eval/eval.go
index 28fe99b..409eda3 100644
--- a/internal/core/eval/eval.go
+++ b/internal/core/eval/eval.go
@@ -1068,7 +1068,7 @@
 // addStruct collates the declarations of a struct.
 //
 // addStruct fulfills two additional pivotal functions:
-//   1) Implement vertex unification (this happends through De Bruijn indices
+//   1) Implement vertex unification (this happens through De Bruijn indices
 //      combined with proper set up of Environments).
 //   2) Implied closedness for definitions.
 //
diff --git a/internal/cuetest/sim.go b/internal/cuetest/sim.go
index 375e3ba..2d527ac 100644
--- a/internal/cuetest/sim.go
+++ b/internal/cuetest/sim.go
@@ -75,7 +75,7 @@
 	}
 	if err = cmd.Run(context.Background()); err != nil {
 		if cfg.Stdout == nil {
-			logf(t, "Ouput:\n%s", buf.String())
+			logf(t, "Output:\n%s", buf.String())
 		}
 		logf(t, "Execution failed: %v", err)
 	}
diff --git a/internal/cuetxtar/txtar.go b/internal/cuetxtar/txtar.go
index 241305f..b24f43a 100644
--- a/internal/cuetxtar/txtar.go
+++ b/internal/cuetxtar/txtar.go
@@ -105,7 +105,7 @@
 	return "", false
 }
 
-// Bool searchs for a line starting with #key: value in the comment and
+// Bool searches for a line starting with #key: value in the comment and
 // returns true if the key exists and the value is true.
 func (t *Test) Bool(key string) bool {
 	s, ok := t.Value(key)
diff --git a/pkg/net/doc.go b/pkg/net/doc.go
index 1e7a237..adea9ac 100644
--- a/pkg/net/doc.go
+++ b/pkg/net/doc.go
@@ -14,7 +14,7 @@
 
 // Package net provides net-related type definitions.
 //
-// The IP-related defintions can be represented as either a string or a list of
+// The IP-related definitions can be represented as either a string or a list of
 // byte values. To allow one format over an other these types can be further
 // constraint using string or [...]. For instance,
 //