Skip to content

Commit

Permalink
cue/parser: remove support for space-separated labels
Browse files Browse the repository at this point in the history
Issue #339

Change-Id: Id3bf16f8f344cd9cfbcb51ce5d3a4359b8effafe
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/5681
Reviewed-by: roger peppe <rogpeppe@gmail.com>
  • Loading branch information
mpvl committed Apr 20, 2020
1 parent 9b62b36 commit c1c4c63
Show file tree
Hide file tree
Showing 18 changed files with 136 additions and 240 deletions.
12 changes: 0 additions & 12 deletions cmd/cue/cmd/fix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,6 @@ for k, v in src {
for k, v in src {
"\(k)": v
}
`,
}, {
name: "templates",
in: `package foo
a: <Name>: { name: Name }
b: <X>: { name: string }
`,
out: `package foo
a: [Name=_]: {name: Name}
b: [string]: {name: string}
`,
// }, {
// name: "slice",
Expand Down
9 changes: 3 additions & 6 deletions cmd/cue/cmd/testdata/script/legacy.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,12 @@ cue fmt foo.cue
cmp foo.cue foo-new.cue

-- expect-stderr --
space-separated labels deprecated as of v0.0.13: try running `cue fmt` on the file to upgrade.:
./foo.cue:1:3
old-style comprehensions deprecated as of v0.0.11: try running `cue fmt` on the file to upgrade.:
./foo.cue:2:8
./foo.cue:1:8
-- foo.cue --
a b: 2
"x": 3 for x in a
-- foo-new.cue --
a: b: 2

for x in a {
"x": 3
}
}
4 changes: 2 additions & 2 deletions cue/ast/astutil/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ everywhere: new
name: "templates",
in: `
foo: {
a: <b>: c: 3
a: [string]: c: 3
}
`,
out: `
foo: {
a: <b>: {
a: [string]: {
c: 3
iam: new
}
Expand Down
14 changes: 7 additions & 7 deletions cue/ast_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,16 @@ func TestCompile(t *testing.T) {
in: `
a: 5 | "a" | true
aa: 5 | *"a" | true
b c: {
b: c: {
cc: { ccc: 3 }
}
d: true
`,
out: "<0>{a: (5 | \"a\" | true), aa: (5 | *\"a\" | true), b: <1>{c: <2>{cc: <3>{ccc: 3}}}, d: true}",
}, {
in: `
a a: { b: a } // referencing ancestor nodes is legal.
a b: a.a // do lookup before merging of nodes
a: a: { b: a } // referencing ancestor nodes is legal.
a: b: a.a // do lookup before merging of nodes
b: a.a // different node as a.a.b, as first node counts
c: a // same node as b, as first node counts
d: a["a"]
Expand Down Expand Up @@ -282,11 +282,11 @@ alias "Y" redeclared in same scope:
}, {
in: `
a: {
<name>: { n: name }
[name=_]: { n: name }
k: 1
}
b: {
<X>: { x: 0, y: 1 }
[X=_]: { x: 0, y: 1 }
v: {}
}
`,
Expand Down Expand Up @@ -347,7 +347,7 @@ b: preference mark not allowed at this position:
out: "unexpected ')':\n test:2:18\nattribute missing ')':\n test:3:3\n<0>{}",
}, {
in: `
a d: {
a: d: {
base
info :: {
...
Expand All @@ -359,7 +359,7 @@ b: preference mark not allowed at this position:
info :: {...}
}
a <Name>: { info :: {
a: [Name=string]: { info :: {
X: "foo"
}}
`,
Expand Down
2 changes: 1 addition & 1 deletion cue/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func TestBuild(t *testing.T) {
import bar "pkg1"
import baz "example.com/foo/pkg2:pkg"
pkg1 Object: 3
pkg1: Object: 3
"Hello \(pkg1.Object)!"`),
}),
`imported and not used: "pkg1" as bar (and 1 more errors)`,
Expand Down
4 changes: 2 additions & 2 deletions cue/builtin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ func TestBuiltins(t *testing.T) {
test("list", `list.Sort([], list.Ascending)`),
`[]`,
}, {
test("list", `list.Sort([2, 3, 1, 4], {x:_, y:_, less: (x<y)})`),
test("list", `list.Sort([2, 3, 1, 4], {x:_, y:_, less: x<y})`),
`[1,2,3,4]`,
}, {
test("list", `list.SortStable([{a:2,v:1}, {a:1,v:2}, {a:1,v:3}], {
Expand Down Expand Up @@ -404,7 +404,7 @@ func TestBuiltins(t *testing.T) {
testExpr(`len({})`),
`0`,
}, {
testExpr(`len({a: 1, b: 2, <foo>: int, _c: 3})`),
testExpr(`len({a: 1, b: 2, [foo=_]: int, _c: 3})`),
`2`,
}, {
testExpr(`len([1, 2, 3])`),
Expand Down
4 changes: 2 additions & 2 deletions cue/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -281,8 +281,8 @@ func TestExport(t *testing.T) {
idx: a[str]
str: string
}
b a b: 4
a b: 3
b: a: b: 4
a: b: 3
}`,
// reference to a must be redirected to outer a through alias
out: unindent(`
Expand Down
2 changes: 1 addition & 1 deletion cue/format/testdata/expressions.golden
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package expressions

c: b: a: 4
c?: bb?: aaa?: 5
c: b: <Name>: a: int
c: b: [Name=string]: a: int
alias = 3.14
"g\("en")"?: 4

Expand Down
6 changes: 3 additions & 3 deletions cue/format/testdata/expressions.input
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ package expressions

b: 3

c b a: 4
c? bb? aaa?: 5
c b <Name> a: int
c: b: a: 4
c?: bb?: aaa?: 5
c: b: [Name=string]: a: int
alias = 3.14
"g\("en")"?: 4

Expand Down
24 changes: 12 additions & 12 deletions cue/instance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ func TestMerge(t *testing.T) {
}, {
desc: "templates",
instances: insts(`
obj <X>: { a: "A" }
obj alpha: { b: 2 }
obj: [string]: { a: "A" }
obj: alpha: { b: 2 }
`,
`
obj <X>: { a: "B" }
obj beta: { b: 3 }
obj: [string]: { a: "B" }
obj: beta: { b: 3 }
`,
),
out: `{obj:{alpha:{a:A,b:2},beta:{a:B,b:3}}}`,
Expand All @@ -71,27 +71,27 @@ func TestMerge(t *testing.T) {
desc: "shared struct",
instances: insts(`
_shared: { a: "A" }
obj <X>: _shared & {}
obj alpha: { b: 2 }
obj: [string]: _shared & {}
obj: alpha: { b: 2 }
`,
`
_shared: { a: "B" }
obj <X>: _shared & {}
obj beta: { b: 3 }
obj: [string]: _shared & {}
obj: beta: { b: 3 }
`,
),
out: `{obj:{alpha:{a:A,b:2},beta:{a:B,b:3}}}`,
}, {
desc: "top-level comprehensions",
instances: insts(`
t: { for k, x in s {"\(k)": 10} }
s <Name>: {}
s foo a: 1
s: [string]: {}
s: foo: a: 1
`,
`
t: { for k, x in s {"\(k)": 10 } }
s <Name>: {}
s bar b: 2
s: [string]: {}
s: bar: b: 2
`,
),
out: `{t:{foo:10,bar:10},s:{foo:{a:1},bar:{b:2}}}`,
Expand Down

0 comments on commit c1c4c63

Please sign in to comment.