cue: add locations for disallowed field

This was the case during regular evaluation, but not for
top-level fields in the API.

All it takes is reusing the error that is already there.

This also "unskips" some errors that were skipped in
the transition to v0.3.

Change-Id: Idc58ddd2c3024ec645313f185c28770bcd074861
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9065
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
diff --git a/cmd/cue/cmd/testdata/script/vet_embed.txt b/cmd/cue/cmd/testdata/script/vet_embed.txt
index 4ba6c25..f8c0995 100644
--- a/cmd/cue/cmd/testdata/script/vet_embed.txt
+++ b/cmd/cue/cmd/testdata/script/vet_embed.txt
@@ -31,6 +31,23 @@
 e: 2
 
 -- expect-foo --
-field c not allowed
+field c not allowed:
+    ./foo.yaml:1:2
+    ./foo.yaml:2:2
+    ./schema.cue:1:1
+    ./schema.cue:3:7
+    ./schema.cue:7:1
 -- expect-stream --
-field d not allowed
+field d not allowed:
+    ./schema.cue:1:1
+    ./schema.cue:3:7
+    ./schema.cue:7:1
+    ./stream.yaml:1:2
+    ./stream.yaml:2:2
+-- expect-stream --
+field d not allowed:
+    ./schema.cue:1:1
+    ./schema.cue:3:7
+    ./schema.cue:7:1
+    ./stream.yaml:1:2
+    ./stream.yaml:2:2
diff --git a/cmd/cue/cmd/testdata/script/vet_expr.txt b/cmd/cue/cmd/testdata/script/vet_expr.txt
index f62a4d9..0d3cbdf 100644
--- a/cmd/cue/cmd/testdata/script/vet_expr.txt
+++ b/cmd/cue/cmd/testdata/script/vet_expr.txt
@@ -1,13 +1,13 @@
-skip 'error messages/ missed disallowed field'
-
 ! cue vet -d '#File' vet.cue data.yaml
 cmp stderr expect-stderr
 
 -- expect-stderr --
 translations.hello.lang: incomplete value string
-translations.hello.lang: conflicting values false and string (mismatched types bool and string)
-field "skip" not allowed in closed struct:
-    ./data.yaml:20:7
+field skip not allowed:
+    ./data.yaml:16:1
+    ./data.yaml:20:1
+    ./vet.cue:1:1
+    ./vet.cue:1:8
 -- vet.cue --
 #File: {
 	translations: [string]: {
diff --git a/cmd/cue/cmd/testdata/script/vet_yaml.txt b/cmd/cue/cmd/testdata/script/vet_yaml.txt
index c926720..e61ed73 100644
--- a/cmd/cue/cmd/testdata/script/vet_yaml.txt
+++ b/cmd/cue/cmd/testdata/script/vet_yaml.txt
@@ -1,12 +1,10 @@
-skip 'error messages'
-
 ! cue vet ./yaml.cue
 cmp stderr expect-stderr
 
 -- expect-stderr --
-phrases: error in call to encoding/yaml.Validate: phrases.quote1.text: incomplete value (!=""):
+phrases: invalid value "phrases:\n  # A quote from Mark Twain.\n  quote1:\n    lang: en\n    attribution: Mark Twain\n\n  # A Norwegian proverb.\n  proverb:\n    lang: no\n    text: Stemmen som sier at du ikke klarer det, lyver." (does not satisfy encoding/yaml.Validate({phrases:{},#Phrase:{lang:=~"^[a-zA-Z0-9-_]{2,}$" | false,text:!=""},#LanguageTag:=~"^[a-zA-Z0-9-_]{2,}$" | false})): error in call to encoding/yaml.Validate: incomplete value !="":
     ./yaml.cue:19:10
-    ./yaml.cue:11:17
+    ./yaml.cue:21:10
 -- yaml.cue --
 import "encoding/yaml"
 
diff --git a/cue/types.go b/cue/types.go
index caad432..2f2379d 100644
--- a/cue/types.go
+++ b/cue/types.go
@@ -1785,6 +1785,9 @@
 	n.Label = v.v.Label
 	n.Closed = v.v.Closed || w.v.Closed
 
+	if err := n.Err(ctx, adt.Finalized); err != nil {
+		return makeValue(v.idx, n)
+	}
 	if err := allowed(ctx, v.v, n); err != nil {
 		return newErrValue(w, err)
 	}
@@ -1818,6 +1821,9 @@
 	n.Parent = v.v.Parent
 	n.Label = v.v.Label
 
+	if err := n.Err(ctx, adt.Finalized); err != nil {
+		return makeValue(v.idx, n)
+	}
 	if err := allowed(ctx, accept.v, n); err != nil {
 		return newErrValue(accept, err)
 	}
diff --git a/cue/types_test.go b/cue/types_test.go
index e2b18e4..80e5021 100644
--- a/cue/types_test.go
+++ b/cue/types_test.go
@@ -91,7 +91,7 @@
 			res := w.Unify(v)
 			return res
 		},
-		want: "_|_(#runSpec.v: field ction not allowed)",
+		want: "_|_(w: field ction not allowed)",
 	}}
 	for _, tc := range testCases {
 		if tc.skip {