cue/cmd/cue: disallow quoted identifiers by default
These were deprecated a while back. Now step up the
enforcement.
Also bumps the syntax check level.
Issue #339
Change-Id: I922bb075114c638e411eaf7d6e8418cf730578d5
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/5780
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cmd/cue/cmd/common.go b/cmd/cue/cmd/common.go
index ce20539..a61fe08 100644
--- a/cmd/cue/cmd/common.go
+++ b/cmd/cue/cmd/common.go
@@ -43,7 +43,7 @@
// - block comments
// - old-style field comprehensions
// - space separator syntax
-const syntaxVersion = -1000 + 13
+const syntaxVersion = -1000 + 100*1 + 2
var defaultConfig = config{
loadCfg: &load.Config{
diff --git a/cue/parser/parser.go b/cue/parser/parser.go
index b576e4a..4a598c0 100644
--- a/cue/parser/parser.go
+++ b/cue/parser/parser.go
@@ -366,6 +366,10 @@
p.comments.add(comment)
}
}
+
+ if p.tok == token.IDENT && p.lit[0] == '`' {
+ p.assertV0(p.pos, 0, 13, "quoted identifiers")
+ }
}
// assertV0 indicates the last version at which a certain feature was
@@ -1131,7 +1135,7 @@
if clauses, _ := p.parseComprehensionClauses(false); clauses != nil {
var expr ast.Expr
- p.assertV0(p.pos, 1, 1, "old-style list comprehensions")
+ p.assertV0(p.pos, 1, 3, "old-style list comprehensions")
if len(elts) != 1 {
p.errf(lbrack.Add(1), "list comprehension must have exactly one element")
}
diff --git a/doc/tutorial/kubernetes/manual/services/k8s.cue b/doc/tutorial/kubernetes/manual/services/k8s.cue
index 381e483..19bf569 100644
--- a/doc/tutorial/kubernetes/manual/services/k8s.cue
+++ b/doc/tutorial/kubernetes/manual/services/k8s.cue
@@ -10,7 +10,7 @@
metadata: labels: x.label
spec: selector: x.label
- spec: ports: [ p for p in x.port ] // convert struct to list
+ spec: ports: [ for p in x.port {p}] // convert struct to list
}
}
// Note that we cannot write
@@ -84,13 +84,13 @@
image: X.image
args: X.args
if len(X.envSpec) > 0 {
- env: [ for k, v in X.envSpec {v, name: k} ]
+ env: [ for k, v in X.envSpec {v, name: k}]
}
ports: [ for k, p in X.expose.port & X.port {
name: k
containerPort: p
- } ]
+ }]
}]
}
@@ -102,7 +102,7 @@
v.kubernetes
name: v.name
- }
+ },
]
}
@@ -120,7 +120,7 @@
if v.readOnly {
readOnly: v.readOnly
}
- }
+ },
]
}
}]