Skip to content

Using @embed annotation without @extern(embed) error is not clear #4010

@DavidGamba

Description

@DavidGamba

What version of CUE are you using (cue version)?

$ cue version
cue version v0.14.0-rc.2

go version go1.24.4
      -buildmode exe
       -compiler gc
  DefaultGODEBUG gotestjsonbuildtext=1,multipathtcp=0,randseednop=0,rsa1024min=0,tlsmlkem=0,x509rsacrt=0,x509usepolicies=0
     CGO_ENABLED 1
          GOARCH arm64
            GOOS darwin
         GOARM64 v8.0
cue.lang.version v0.14.0

Does this issue reproduce with the latest stable release?

yes

What did you do?

exec cue cmd dump

-- b.txt --
hello
-- cue.mod/module.cue --
module: "mod.com"
language: {
	version: "v0.14.0"
}
-- dump_tool.cue --
package x

import (
	"encoding/yaml"
	"tool/cli"
)

objects: [for v in objectSets for x in v {x}]

objectSets: [
	obj,
]

command: dump: {
	task: print: cli.Print & {
		text: yaml.MarshalStream(objects)
	}
}
-- x.cue --
package x

obj: a: txt: string
obj: a: {
	txt: _ @embed(file=b.txt, type=text)
}

What did you expect to see?

An error along the lines of: use of @embed anotation without an @external(embed) clause.

What did you see instead?

command.dump.task.print.text: invalid string argument: error in call to encoding/yaml.MarshalStream: incomplete value string:
    ./dump_tool.cue:15:8
    ./dump_tool.cue:16:3
    ./dump_tool.cue:16:9
    ./x.cue:3:14
    tool/cli:5:3

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions