cue: pass error from Fill
Change-Id: I72a6389980b134e4e5aba9b6d99ddb8613c48051
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2301
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
diff --git a/cue/instance.go b/cue/instance.go
index f793d3c..d27db43 100644
--- a/cue/instance.go
+++ b/cue/instance.go
@@ -22,7 +22,6 @@
"cuelang.org/go/cue/errors"
"cuelang.org/go/cue/token"
"cuelang.org/go/internal"
- "golang.org/x/exp/errors/fmt"
)
// An Instance defines a single configuration based on a collection of
@@ -295,9 +294,16 @@
value := convert(ctx, root, x)
eval := binOp(ctx, baseValue{}, opUnify, root, value)
// TODO: validate recursively?
- st, ok := eval.(*structLit)
- if !ok {
- fmt.Errorf("structure at path did not resolve in struct")
+ err := inst.Err
+ var st *structLit
+ switch x := eval.(type) {
+ case *structLit:
+ st = x
+ default:
+ // This should not happen.
+ err = errors.Newf(x.Pos(), "error filling struct")
+ case *bottom:
+ err = inst.Value().toErr(x)
}
inst = &Instance{
rootStruct: st,
@@ -308,9 +314,9 @@
ImportPath: inst.ImportPath,
Name: inst.Name,
Incomplete: inst.Incomplete,
- Err: inst.Err,
+ Err: err,
- complete: true,
+ complete: err != nil,
}
- return inst, nil
+ return inst, err
}
diff --git a/go.mod b/go.mod
index 578840c..79e49b3 100644
--- a/go.mod
+++ b/go.mod
@@ -17,7 +17,6 @@
github.com/retr0h/go-gilt v0.0.0-20190206215556-f73826b37af2
github.com/spf13/cobra v0.0.3
github.com/spf13/pflag v1.0.3
- golang.org/x/exp/errors v0.0.0-20181221233300-b68661188fbf
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f
golang.org/x/text v0.3.2
golang.org/x/tools v0.0.0-20181210225255-6a3e9aa2ab77
diff --git a/go.sum b/go.sum
index b33cf2f..5031a3f 100644
--- a/go.sum
+++ b/go.sum
@@ -53,8 +53,6 @@
github.com/xeipuuv/gojsonpointer v0.0.0-20170225233418-6fe8760cad35/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
github.com/xeipuuv/gojsonreference v0.0.0-20150808065054-e02fc20de94c/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v0.0.0-20171230112544-511d08a359d1/go.mod h1:5yf86TLmAcydyeJq5YvxkGPE2fm/u4myDekKRoLuqhs=
-golang.org/x/exp/errors v0.0.0-20181221233300-b68661188fbf h1:4SQtY0VxhI0RZe/PFmCCfHyaPVuC5DgyXEqehsAWjwc=
-golang.org/x/exp/errors v0.0.0-20181221233300-b68661188fbf/go.mod h1:YgqsNsAu4fTvlab/7uiYK9LJrCIzKg/NiZUIH1/ayqo=
golang.org/x/lint v0.0.0-20181011164241-5906bd5c48cd/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd h1:nTDtHvHSdCn1m6ITfMRqtOd/9+7a3s8RBNOZ3eYZzJA=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=