cue: fix error formatting issues
Change-Id: Ifca769c814d2f79aecdc6c3b811093147f27819e
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2860
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/errors/errors.go b/cue/errors/errors.go
index 93dd7e7..fc5aed1 100644
--- a/cue/errors/errors.go
+++ b/cue/errors/errors.go
@@ -369,8 +369,7 @@
case 1:
return p[0].Msg()
}
- format, args = p[0].Msg()
- return "%s (and %d more errors)", append(args, len(p)-1)
+ return "%s (and %d more errors)", []interface{}{p[0], len(p) - 1}
}
// Position reports the primary position for the first error, if any.
diff --git a/cue/go_test.go b/cue/go_test.go
index fe8133b..e16017e 100644
--- a/cue/go_test.go
+++ b/cue/go_test.go
@@ -179,7 +179,7 @@
struct {
A int `cue:"<"` // invalid
}{},
- "_|_(invalid tag \"<\" for field \"A\": expected operand, found 'EOF' )",
+ "_|_(invalid tag \"<\" for field \"A\": expected operand, found 'EOF')",
}, {
struct {
A int `json:"-"` // skip
diff --git a/cue/parser/parser.go b/cue/parser/parser.go
index 045b026..7b1f78b 100644
--- a/cue/parser/parser.go
+++ b/cue/parser/parser.go
@@ -378,9 +378,9 @@
}
if p.tok.IsLiteral() {
- p.errf(pos, "expected %s, found '%s'", obj, p.tok)
- } else {
p.errf(pos, "expected %s, found '%s' %s", obj, p.tok, p.lit)
+ } else {
+ p.errf(pos, "expected %s, found '%s'", obj, p.tok)
}
}
diff --git a/cue/parser/testdata/commas.src b/cue/parser/testdata/commas.src
index 0a75770..3e93a54 100644
--- a/cue/parser/testdata/commas.src
+++ b/cue/parser/testdata/commas.src
@@ -5,7 +5,7 @@
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
-//
+//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -18,7 +18,7 @@
import "path/to/pkg"
import name "path/to/pkg"
-import . /* ERROR "expected 'STRING', found '.' " */
+import . /* ERROR "expected 'STRING', found '.'" */
import /* ERROR "expected 'STRING', found newline" */
import err /* ERROR "expected 'STRING', found newline" */