Skip to content

Commit 14ec6e2

Browse files
committed
internal/core/export: add real Final option
Force incomplete errors only when really finalizing. Fixes a few bugs that are related to formatting API-generated values. This is a bit hard to test here, but will fixing things in a followup CL. Change-Id: Ia75272409c50f048143d0d254d04e625822dd26a Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9483 Reviewed-by: CUE cueckoo <[email protected]> Reviewed-by: Paul Jolly <[email protected]>
1 parent f044ad1 commit 14ec6e2

File tree

3 files changed

+7
-14
lines changed

3 files changed

+7
-14
lines changed

internal/core/export/export.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,12 @@ const debug = false
3232
type Profile struct {
3333
Simplify bool
3434

35+
// Final reports incomplete errors as errors.
36+
Final bool
37+
3538
// TakeDefaults is used in Value mode to drop non-default values.
3639
TakeDefaults bool
3740

38-
// TODO:
39-
// IncludeDocs
4041
ShowOptional bool
4142
ShowDefinitions bool
4243

@@ -65,6 +66,7 @@ var Simplified = &Profile{
6566
var Final = &Profile{
6667
Simplify: true,
6768
TakeDefaults: true,
69+
Final: true,
6870
}
6971

7072
var Raw = &Profile{

internal/core/export/testdata/let.txtar

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,8 @@ y: Y & Y_1
129129
name: "two"
130130
}
131131
}]
132-
let filepath = "kind-\(cfg.name)"
133-
files: {
134-
"\(filepath)": {
135-
patches: cfg
136-
}
137-
} & {
138-
"\(filepath)": {
139-
patches: cfg
140-
}
141-
}
142-
y: "foo"
132+
files: _|_ // invalid interpolation: invalid interpolation: files: undefined field name (and 3 more errors)
133+
y: "foo"
143134
}
144135
== All
145136
{

internal/core/export/value.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func (e *exporter) vertex(n *adt.Vertex) (result ast.Expr) {
6969
result = e.structComposite(n, attrs)
7070
}
7171

72-
case !x.IsIncomplete() || len(n.Conjuncts) == 0:
72+
case !x.IsIncomplete() || len(n.Conjuncts) == 0 || e.cfg.Final:
7373
result = e.bottom(x)
7474
}
7575

0 commit comments

Comments
 (0)