cue: eliminate generation of block quotes
Issue #87
Change-Id: I73ac50d03372eccef55f510a582e8c49e7434d0a
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/3262
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cue/export.go b/cue/export.go
index 9fea698..3d32ba8 100644
--- a/cue/export.go
+++ b/cue/export.go
@@ -545,10 +545,10 @@
case *bottom:
err := &ast.BottomLit{}
if x.format != "" {
- comment := &ast.Comment{Text: "/* " + x.msg() + " */"}
+ comment := &ast.Comment{Text: "// " + x.msg()}
err.AddComment(&ast.CommentGroup{
Line: true,
- Position: 1,
+ Position: 2,
List: []*ast.Comment{comment},
})
}
diff --git a/cue/export_test.go b/cue/export_test.go
index 5fed65a..b1c179e 100644
--- a/cue/export_test.go
+++ b/cue/export_test.go
@@ -96,11 +96,19 @@
s: "abc"
}
b: 2.0
- c: _|_ /* undefined field "c" */
- d: _|_ /* undefined field "d" */
- e: _|_ /* undefined field "t" */
+ c: _|_ // undefined field "c"
+ d: _|_ // undefined field "d"
+ e: _|_ // undefined field "t"
}`),
}, {
+ // Insert comma between error and inserted message.
+ in: `{ a: [ 3&4] }`,
+ out: unindent(`
+ {
+ a: [_|_, // conflicting values 3 and 4
+ ]
+ }`),
+ }, {
in: `{
a: 5*[int]
a: [1, 2, ...]
diff --git a/cue/format/printer.go b/cue/format/printer.go
index 24a973c..3542310 100644
--- a/cue/format/printer.go
+++ b/cue/format/printer.go
@@ -194,10 +194,6 @@
}
func (p *printer) writeWhitespace(ws whiteSpace) {
- if debug {
- p.output = append(p.output, fmt.Sprintf("/*=%x=*/", p.allowed)...) // do not update f.pos!
- }
-
if ws&comma != 0 {
switch {
case ws&(newsection|newline|formfeed) != 0,
@@ -304,9 +300,6 @@
p.output = append(p.output, tabwriter.Escape)
}
- if debug {
- p.output = append(p.output, fmt.Sprintf("/*%s*/", p.pos)...) // do not update f.pos!
- }
p.output = append(p.output, s...)
if isLit {
diff --git a/doc/tutorial/basics/bottom.md b/doc/tutorial/basics/bottom.md
index b3f9b24..e76188f 100644
--- a/doc/tutorial/basics/bottom.md
+++ b/doc/tutorial/basics/bottom.md
@@ -32,7 +32,8 @@
`$ cue eval -i bottom.cue`
```
list: [0, 1, 2]
-a: _|_ /* conflicting values 4 and 5 */
-l: [1, _|_ /* conflicting values 2 and 3 */]
-val: _|_ /* index 3 out of bounds */
+a: _|_ // conflicting values 4 and 5
+l: [1, _|_, // conflicting values 2 and 3
+]
+val: _|_ // index 3 out of bounds
```
diff --git a/doc/tutorial/basics/cycle.md b/doc/tutorial/basics/cycle.md
index 3855994..50c623b 100644
--- a/doc/tutorial/basics/cycle.md
+++ b/doc/tutorial/basics/cycle.md
@@ -33,6 +33,6 @@
```
x: 200
y: 100
-a: _|_ /* cycle detected */
-b: _|_ /* cycle detected */
+a: _|_ // cycle detected
+b: _|_ // cycle detected
```
diff --git a/doc/tutorial/basics/interpolfield.md b/doc/tutorial/basics/interpolfield.md
index 896b7aa..e928aa2 100644
--- a/doc/tutorial/basics/interpolfield.md
+++ b/doc/tutorial/basics/interpolfield.md
@@ -25,7 +25,7 @@
sandwich: {
type: "Cheese"
hasButter: true
- butterAndCheese: _|_ /* reference "hasCheese" not found */
+ butterAndCheese: _|_ // reference "hasCheese" not found
hasCheese: true
}
```
\ No newline at end of file
diff --git a/doc/tutorial/basics/lists.md b/doc/tutorial/basics/lists.md
index b349c56..5bde4be 100644
--- a/doc/tutorial/basics/lists.md
+++ b/doc/tutorial/basics/lists.md
@@ -41,5 +41,5 @@
IP: [uint8, uint8, uint8, uint8]
PrivateIP: [10, uint8, uint8, uint8] | [192, 168, uint8, uint8] | [172, >=16 & <=32, uint8, uint8]
myIP: [10, 2, 3, 4]
-yourIP: _|_ /* empty disjunction: [((10 & (int & >=0 & int & <=255)) & 11),((int & >=0 & int & <=255) & 1),((int & >=0 & int & <=255) & 2),((int & >=0 & int & <=255) & 3)] */
+yourIP: _|_ // empty disjunction: [((10 & (int & >=0 & int & <=255)) & 11),((int & >=0 & int & <=255) & 1),((int & >=0 & int & <=255) & 2),((int & >=0 & int & <=255) & 3)]
```
\ No newline at end of file
diff --git a/doc/tutorial/basics/numbers.md b/doc/tutorial/basics/numbers.md
index 08d9b9c..e5495cc 100644
--- a/doc/tutorial/basics/numbers.md
+++ b/doc/tutorial/basics/numbers.md
@@ -34,6 +34,6 @@
```
a: 4
b: 4.0
-c: _|_ /* conflicting values int and 4.0 (mismatched types int and float) */
+c: _|_ // conflicting values int and 4.0 (mismatched types int and float)
d: 4
```
diff --git a/doc/tutorial/basics/rangedef.md b/doc/tutorial/basics/rangedef.md
index f7fe8ab..ea97bd5 100644
--- a/doc/tutorial/basics/rangedef.md
+++ b/doc/tutorial/basics/rangedef.md
@@ -43,7 +43,7 @@
<!-- result -->
`$ cue eval -i range.cue`
```
-a: _|_ /* invalid value -1 (out of bound int & >=0) */
+a: _|_ // invalid value -1 (out of bound int & >=0)
b: 128
c: 2000000000
```
\ No newline at end of file
diff --git a/doc/tutorial/basics/ranges.md b/doc/tutorial/basics/ranges.md
index b552bf4..fa637ba 100644
--- a/doc/tutorial/basics/ranges.md
+++ b/doc/tutorial/basics/ranges.md
@@ -35,9 +35,9 @@
`$ cue eval -i bounds.cue`
```
a: 3.5
-b: _|_ /* conflicting values ri and 3.5 (mismatched types int and float) */
+b: _|_ // conflicting values ri and 3.5 (mismatched types int and float)
c: 3
d: "ma"
-e: _|_ /* invalid value "mu" (out of bound <"mo") */
+e: _|_ // invalid value "mu" (out of bound <"mo")
r1: >=5 & <8
```
diff --git a/doc/tutorial/basics/regexp.md b/doc/tutorial/basics/regexp.md
index 09f0e3e..c1f2abd 100644
--- a/doc/tutorial/basics/regexp.md
+++ b/doc/tutorial/basics/regexp.md
@@ -35,5 +35,5 @@
b: true
c: =~"^[a-z]{3}$"
d: "foo"
-e: _|_ /* invalid value "foo bar" (does not match =~"^[a-z]{3}$") */
+e: _|_ // invalid value "foo bar" (does not match =~"^[a-z]{3}$")
```
diff --git a/doc/tutorial/basics/unification.md b/doc/tutorial/basics/unification.md
index f8254ac..e6bb943 100644
--- a/doc/tutorial/basics/unification.md
+++ b/doc/tutorial/basics/unification.md
@@ -45,16 +45,16 @@
q: {
x: 1
y: 2
- z: _|_ /* conflicting values 3 and 4 */
+ z: _|_ // conflicting values 3 and 4
}
r: {
x: 1
y: 2
- z: _|_ /* conflicting values 3 and 4 */
+ z: _|_ // conflicting values 3 and 4
}
s: {
x: 1
y: 2
- z: _|_ /* conflicting values 4 and 3 */
+ z: _|_ // conflicting values 4 and 3
}
```
\ No newline at end of file
diff --git a/doc/tutorial/kubernetes/testdata/manual.out b/doc/tutorial/kubernetes/testdata/manual.out
index 6019a37..e4a2183 100644
--- a/doc/tutorial/kubernetes/testdata/manual.out
+++ b/doc/tutorial/kubernetes/testdata/manual.out
@@ -31,7 +31,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -81,7 +81,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -248,7 +248,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -417,7 +417,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -584,7 +584,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -751,7 +751,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -920,7 +920,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -1087,7 +1087,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -1256,7 +1256,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -1306,7 +1306,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -1459,7 +1459,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -1785,7 +1785,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -1857,7 +1857,8 @@
name: "grpc"
containerPort: 7788
}]
- volumeMounts: [_|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ ]
}]
volumes: [{
name: "secret-volume"
@@ -2006,7 +2007,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -2081,7 +2082,8 @@
name: "https"
containerPort: 7443
}]
- volumeMounts: [_|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ ]
}]
volumes: [{
name: "secret-volume"
@@ -2202,7 +2204,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -2271,7 +2273,8 @@
name: "http"
containerPort: 8080
}]
- volumeMounts: [_|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ ]
}]
volumes: [{
name: "secret-updater"
@@ -2372,7 +2375,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -2446,7 +2449,8 @@
name: "https"
containerPort: 7788
}]
- volumeMounts: [_|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ ]
}]
volumes: [{
name: "secret-volume"
@@ -2558,7 +2562,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -2608,7 +2612,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -2630,7 +2634,7 @@
"event-server": "events:7788"
logdir: "/logs"
}
- volume: _|_ /* incomplete */
+ volume: _|_ // incomplete
}
@@ -2686,7 +2690,10 @@
name: "client"
containerPort: 8080
}]
- volumeMounts: [_|_ /* non-concrete value bool */, _|_ /* non-concrete value bool */, _|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ _|_, // non-concrete value bool
+ _|_, // non-concrete value bool
+ ]
livenessProbe: {
httpGet: {
path: "/debug/health"
@@ -2857,7 +2864,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -2879,7 +2886,7 @@
"event-server": "events:7788"
logdir: "/logs"
}
- volume: _|_ /* incomplete */
+ volume: _|_ // incomplete
}
@@ -2935,7 +2942,10 @@
name: "client"
containerPort: 8080
}]
- volumeMounts: [_|_ /* non-concrete value bool */, _|_ /* non-concrete value bool */, _|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ _|_, // non-concrete value bool
+ _|_, // non-concrete value bool
+ ]
livenessProbe: {
httpGet: {
path: "/debug/health"
@@ -3103,7 +3113,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -3125,7 +3135,7 @@
"event-server": "events:7788"
logdir: "/logs"
}
- volume: _|_ /* incomplete */
+ volume: _|_ // incomplete
}
@@ -3181,7 +3191,9 @@
name: "client"
containerPort: 8080
}]
- volumeMounts: [_|_ /* non-concrete value bool */, _|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ _|_, // non-concrete value bool
+ ]
livenessProbe: {
httpGet: {
path: "/debug/health"
@@ -3334,7 +3346,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -3356,7 +3368,7 @@
"event-server": "events:7788"
logdir: "/logs"
}
- volume: _|_ /* incomplete */
+ volume: _|_ // incomplete
}
@@ -3412,7 +3424,9 @@
name: "client"
containerPort: 8080
}]
- volumeMounts: [_|_ /* non-concrete value bool */, _|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ _|_, // non-concrete value bool
+ ]
livenessProbe: {
httpGet: {
path: "/debug/health"
@@ -3564,7 +3578,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -3586,7 +3600,7 @@
"event-server": "events:7788"
logdir: "/logs"
}
- volume: _|_ /* incomplete */
+ volume: _|_ // incomplete
}
@@ -3642,7 +3656,9 @@
name: "client"
containerPort: 8080
}]
- volumeMounts: [_|_ /* non-concrete value bool */, _|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ _|_, // non-concrete value bool
+ ]
livenessProbe: {
httpGet: {
path: "/debug/health"
@@ -3798,7 +3814,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -3820,7 +3836,7 @@
"event-server": "events:7788"
logdir: "/logs"
}
- volume: _|_ /* incomplete */
+ volume: _|_ // incomplete
}
@@ -3876,7 +3892,9 @@
name: "client"
containerPort: 8080
}]
- volumeMounts: [_|_ /* non-concrete value bool */, _|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ _|_, // non-concrete value bool
+ ]
livenessProbe: {
httpGet: {
path: "/debug/health"
@@ -4032,7 +4050,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -4054,7 +4072,7 @@
"event-server": "events:7788"
logdir: "/logs"
}
- volume: _|_ /* incomplete */
+ volume: _|_ // incomplete
}
@@ -4226,7 +4244,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -4248,7 +4266,7 @@
"event-server": "events:7788"
logdir: "/logs"
}
- volume: _|_ /* incomplete */
+ volume: _|_ // incomplete
}
@@ -4285,7 +4303,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -4365,7 +4383,9 @@
name: "alertmanager"
containerPort: 9093
}]
- volumeMounts: [_|_ /* non-concrete value bool */, _|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ _|_, // non-concrete value bool
+ ]
}]
volumes: [{
name: "alertmanager"
@@ -4540,7 +4560,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -4622,7 +4642,8 @@
name: "web"
containerPort: 8080
}]
- volumeMounts: [_|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ ]
resources: {
requests: {
cpu: "100m"
@@ -4765,7 +4786,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -4843,7 +4864,9 @@
containerPort: 9100
hostPort: 9100
}]
- volumeMounts: [_|_ /* non-concrete value bool */, _|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ _|_, // non-concrete value bool
+ ]
resources: {
requests: {
cpu: "100m"
@@ -4999,7 +5022,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -5080,7 +5103,8 @@
name: "web"
containerPort: 9090
}]
- volumeMounts: [_|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ ]
}]
volumes: [{
name: "config-volume"
@@ -5690,7 +5714,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -5740,7 +5764,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -5809,7 +5833,8 @@
name: "client"
containerPort: 4180
}]
- volumeMounts: [_|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ ]
}]
volumes: [{
name: "config-volume"
@@ -6030,7 +6055,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -6105,7 +6130,8 @@
name: "https"
containerPort: 7443
}]
- volumeMounts: [_|_ /* non-concrete value bool */]
+ volumeMounts: [_|_, // non-concrete value bool
+ ]
}]
volumes: [{
name: "secret-volume"
@@ -6215,7 +6241,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}
@@ -6293,11 +6319,12 @@
name: "https"
containerPort: 443
}]
- volumeMounts: [_|_ /* non-concrete value bool */, {
- name: "config-volume"
- mountPath: "/etc/nginx/nginx.conf"
- subPath: "nginx.conf"
- }]
+ volumeMounts: [_|_, // non-concrete value bool
+ {
+ name: "config-volume"
+ mountPath: "/etc/nginx/nginx.conf"
+ subPath: "nginx.conf"
+ }]
}]
volumes: [{
name: "secret-volume"
@@ -6829,7 +6856,7 @@
kubernetes: {
spec: {
template: {
- spec: _|_ /* undefined field "volume" */
+ spec: _|_ // undefined field "volume"
metadata: {
labels: label
}