cue: deprecate :: and combining bulk optional fields with other fields
Change-Id: I8d88b77fef15ded0933ea3614a3549c467eaae2d
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6241
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cmd/cue/cmd/common.go b/cmd/cue/cmd/common.go
index a67fe94..76ed429 100644
--- a/cmd/cue/cmd/common.go
+++ b/cmd/cue/cmd/common.go
@@ -41,7 +41,7 @@
// - block comments
// - old-style field comprehensions
// - space separator syntax
-const syntaxVersion = -1000 + 100*1 + 2
+const syntaxVersion = -1000 + 100*2 + 1
var defaultConfig = config{
loadCfg: &load.Config{
diff --git a/cmd/cue/cmd/script_test.go b/cmd/cue/cmd/script_test.go
index 6e346e8..0c341e1 100644
--- a/cmd/cue/cmd/script_test.go
+++ b/cmd/cue/cmd/script_test.go
@@ -24,7 +24,7 @@
func TestLatest(t *testing.T) {
filepath.Walk("testdata/script", func(fullpath string, info os.FileInfo, err error) error {
if !strings.HasSuffix(fullpath, ".txt") ||
- strings.HasPrefix(filepath.Base(fullpath), "legacy") {
+ strings.HasPrefix(filepath.Base(fullpath), "fix") {
return nil
}
diff --git a/cmd/cue/cmd/testdata/script/legacy.txt b/cmd/cue/cmd/testdata/script/legacy.txt
deleted file mode 100644
index 18d4cab..0000000
--- a/cmd/cue/cmd/testdata/script/legacy.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-cue eval foo.cue
-cmp stderr expect-stderr
-
-cue export foo.cue
-cmp stderr expect-stderr
-
-cue fmt foo.cue
-cmp foo.cue bar.cue
-
--- expect-stderr --
--- foo.cue --
-a: [1]
-b: [ x for x in a ]
-
-X = foo
--- bar.cue --
-a: [1]
-b: [ for x in a { x } ]
-
-let X = foo
\ No newline at end of file
diff --git a/cue/load/config.go b/cue/load/config.go
index cdea276..e08e32f 100644
--- a/cue/load/config.go
+++ b/cue/load/config.go
@@ -474,7 +474,10 @@
c.loadFunc = c.loader.loadFunc()
if c.Context == nil {
- c.Context = build.NewContext(build.Loader(c.loadFunc))
+ c.Context = build.NewContext(
+ build.Loader(c.loadFunc),
+ build.ParseFile(c.loader.cfg.ParseFile),
+ )
}
return &c, nil
diff --git a/cue/parser/interface.go b/cue/parser/interface.go
index de1cf1f..5ad5459 100644
--- a/cue/parser/interface.go
+++ b/cue/parser/interface.go
@@ -17,8 +17,6 @@
package parser
import (
- "fmt"
-
"cuelang.org/go/cue/ast"
"cuelang.org/go/cue/ast/astutil"
"cuelang.org/go/cue/errors"
@@ -96,7 +94,7 @@
}
func (e *DeprecationError) Error() string {
- return fmt.Sprintf("try running `cue fmt` on the file to upgrade.")
+ return "try running `cue fix` on the file or module to upgrade"
}
// Latest specifies the latest version of the parser, effectively setting
diff --git a/cue/parser/parser.go b/cue/parser/parser.go
index 436a42c..9d96e8f 100644
--- a/cue/parser/parser.go
+++ b/cue/parser/parser.go
@@ -726,7 +726,7 @@
if len(list) > 1 {
for _, d := range list {
if internal.IsBulkField(d) {
- p.assertV0(p.pos, 1, 3, `only one bulk optional field allowed per struct`)
+ p.assertV0(p.pos, 2, 0, `combining bulk optional fields with other fields`)
break
}
}
@@ -890,6 +890,9 @@
m.TokenPos = p.pos
m.Token = p.tok
+ if p.tok == token.ISA {
+ p.assertV0(p.pos, 2, 0, "use of '::'")
+ }
if p.tok != token.COLON && p.tok != token.ISA {
p.errorExpected(pos, "':' or '::'")
}
@@ -923,6 +926,9 @@
m.TokenPos = p.pos
m.Token = p.tok
+ if p.tok == token.ISA {
+ p.assertV0(p.pos, 2, 0, "use of '::'")
+ }
if p.tok != token.COLON && p.tok != token.ISA {
if p.tok.IsLiteral() {
p.errf(p.pos, "expected ':' or '::'; found %s", p.lit)