Skip to content

Commit

Permalink
internal/core/export: add real Final option
Browse files Browse the repository at this point in the history
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 <cueckoo@gmail.com>
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
  • Loading branch information
mpvl committed Apr 23, 2021
1 parent f044ad1 commit 14ec6e2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 14 deletions.
6 changes: 4 additions & 2 deletions internal/core/export/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ const debug = false
type Profile struct {
Simplify bool

// Final reports incomplete errors as errors.
Final bool

// TakeDefaults is used in Value mode to drop non-default values.
TakeDefaults bool

// TODO:
// IncludeDocs
ShowOptional bool
ShowDefinitions bool

Expand Down Expand Up @@ -65,6 +66,7 @@ var Simplified = &Profile{
var Final = &Profile{
Simplify: true,
TakeDefaults: true,
Final: true,
}

var Raw = &Profile{
Expand Down
13 changes: 2 additions & 11 deletions internal/core/export/testdata/let.txtar
Original file line number Diff line number Diff line change
Expand Up @@ -129,17 +129,8 @@ y: Y & Y_1
name: "two"
}
}]
let filepath = "kind-\(cfg.name)"
files: {
"\(filepath)": {
patches: cfg
}
} & {
"\(filepath)": {
patches: cfg
}
}
y: "foo"
files: _|_ // invalid interpolation: invalid interpolation: files: undefined field name (and 3 more errors)
y: "foo"
}
== All
{
Expand Down
2 changes: 1 addition & 1 deletion internal/core/export/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (e *exporter) vertex(n *adt.Vertex) (result ast.Expr) {
result = e.structComposite(n, attrs)
}

case !x.IsIncomplete() || len(n.Conjuncts) == 0:
case !x.IsIncomplete() || len(n.Conjuncts) == 0 || e.cfg.Final:
result = e.bottom(x)
}

Expand Down

0 comments on commit 14ec6e2

Please sign in to comment.