cue: avoid early evaluation in several cases
Change-Id: Id7aa7d83b44732530805ed00bd44ece8412c6dc1
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/1786
Reviewed-by: Marcel van Lohuizen <mpvl@google.com>
diff --git a/cue/ast.go b/cue/ast.go
index 4c5ece5..c4a2366 100644
--- a/cue/ast.go
+++ b/cue/ast.go
@@ -112,9 +112,11 @@
ctx := v.ctx()
label := v.label(n.Name, true)
if r := v.resolveRoot; r != nil {
- if a := r.lookup(v.ctx(), label); a.val() != nil {
- return &selectorExpr{newExpr(n),
- &nodeRef{baseValue: newExpr(n), node: r}, label}
+ for _, a := range r.arcs {
+ if a.feature == label {
+ return &selectorExpr{newExpr(n),
+ &nodeRef{baseValue: newExpr(n), node: r}, label}
+ }
}
if v.inSelector > 0 {
if p := getBuiltinShorthandPkg(ctx, n.Name); p != nil {
@@ -131,6 +133,8 @@
if err != nil {
return ctx.mkErr(newNode(imp), "illformed import spec")
}
+ // TODO: allow builtin *and* imported package. The result is a unified
+ // struct.
if p := getBuiltinPkg(ctx, path); p != nil {
return p
}