cue icon indicating copy to clipboard operation
cue copied to clipboard

"compiler bug" when running a command with duplicate tags

Open jorpic opened this issue 2 years ago • 2 comments

I accidentally specified tag value twice and got this "compiler bug" error:

$ cue cmd -t who=me -t who=me hello
command.hello.print2.cmd: reference "who" set to unknown node in AST; this can result from incorrect API usage or a compiler bug:
    ./hello_tool.cue:11:22
exit status 1

This is a minor inconvenience but seems it is easy to check t.hasReplacement in load.injectTags() and throw a helpful error message.

jorpic avatar Jul 02 '22 20:07 jorpic

Would you mind providing a reproducer? See https://github.com/cue-lang/cue/wiki/Creating-test-or-performance-reproducers#creating-a-txtar-archive.

mvdan avatar Jul 04 '22 12:07 mvdan

! exec cue cmd -t who=me -t who=me hello
cmp stderr stderr.golden
-- hello_tool.cue --
package hello
import "tool/exec"
who: string @tag(who)
command: hello: {
  print2: exec.Run & {
    cmd: "echo Hello \(who)!"
  }
}
-- stderr.golden --
command.hello.print2.cmd: reference "who" set to unknown node in AST; this can result from incorrect API usage or a compiler bug:
    ./hello_tool.cue:6:24

Please ignore my suggestion to check t.hasReplacement in load.injectTags. Seems like cue eval successfully handles duplicate tags during unification.

! exec cue eval -t who=me -t who=not-me hello.cue
cmp stderr stderr.golden
-- hello.cue --
who: string @tag(who)
message: "Hello \(who)!"
-- stderr.golden --
who: conflicting values "not-me" and "me"
who: invalid interpolation: conflicting values "not-me" and "me":
    ./hello.cue:2:10

jorpic avatar Jul 05 '22 17:07 jorpic

Still appears to reproduce as of 12908b32a9a7.

mvdan avatar Jun 13 '23 16:06 mvdan