cmd/cue/cmd: fix resolution of hidden values across tools
Bug only manifested in combination with modules.
Fixes #924
Change-Id: I8bdfd4975e065e4fa2fbc967fcc8f06b31f82d49
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/9524
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
diff --git a/cmd/cue/cmd/common.go b/cmd/cue/cmd/common.go
index ac06401..996b977 100644
--- a/cmd/cue/cmd/common.go
+++ b/cmd/cue/cmd/common.go
@@ -746,6 +746,9 @@
}
}
+ // Set path equal to the package from which it is loading.
+ ti.ImportPath = binst[0].ImportPath
+
inst = inst.Build(ti)
return inst, inst.Err
}
diff --git a/cmd/cue/cmd/testdata/script/cmd_echo.txt b/cmd/cue/cmd/testdata/script/cmd_echo.txt
index 03be9c8..a0dac45 100644
--- a/cmd/cue/cmd/testdata/script/cmd_echo.txt
+++ b/cmd/cue/cmd/testdata/script/cmd_echo.txt
@@ -1,6 +1,12 @@
cue cmd echo
stdout 'Hello World!'
+cue cmd echohidden
+stdout 'Hello World!'
+
+-- cue.mod/module.cue --
+module: "example.com/foo"
+
-- data.cue --
package hello
@@ -24,4 +30,17 @@
text: echo.stdout
}
}
--- cue.mod --
\ No newline at end of file
+
+// Issue #924
+command: echohidden: {
+ echo: {
+ kind: "exec"
+ cmd: "echo Hello \(_who)!"
+ stdout: string
+ }
+
+ task: display: {
+ kind: "print"
+ text: echo.stdout
+ }
+}
\ No newline at end of file