Skip to content

Commit

Permalink
cue: deprecate :: and combining bulk optional fields with other fields
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mpvl committed Jun 6, 2020
1 parent 53d18cc commit 7efeb70
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 27 deletions.
2 changes: 1 addition & 1 deletion cmd/cue/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
// - 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{
Expand Down
2 changes: 1 addition & 1 deletion cmd/cue/cmd/script_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
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
}

Expand Down
20 changes: 0 additions & 20 deletions cmd/cue/cmd/testdata/script/legacy.txt

This file was deleted.

5 changes: 4 additions & 1 deletion cue/load/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,10 @@ func (c Config) complete() (cfg *Config, err error) {
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
Expand Down
4 changes: 1 addition & 3 deletions cue/parser/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
package parser

import (
"fmt"

"cuelang.org/go/cue/ast"
"cuelang.org/go/cue/ast/astutil"
"cuelang.org/go/cue/errors"
Expand Down Expand Up @@ -96,7 +94,7 @@ type DeprecationError struct {
}

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
Expand Down
8 changes: 7 additions & 1 deletion cue/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ func (p *parser) parseFieldList() (list []ast.Decl) {
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
}
}
Expand Down Expand Up @@ -890,6 +890,9 @@ func (p *parser) parseField() (decl ast.Decl) {

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 '::'")
}
Expand Down Expand Up @@ -923,6 +926,9 @@ func (p *parser) parseField() (decl ast.Decl) {

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)
Expand Down

0 comments on commit 7efeb70

Please sign in to comment.