cue icon indicating copy to clipboard operation
cue copied to clipboard

cue: ParsePath does not accept index as first element of path

Open rogpeppe opened this issue 1 year ago • 0 comments

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

$ cue version
v0.10.0

Does this issue reproduce with the latest stable release?

Yes

What did you do?

exec go mod tidy
exec go run .
-- go.mod --
module test

require cuelang.org/go v0.10.0

-- main.go --
package main

import (
	"log"

	"cuelang.org/go/cue"
)

func main() {
	p := cue.MakePath(cue.Index(2))
	if err := p.Err(); err != nil {
		log.Fatal(err)
	}
	q := cue.ParsePath(p.String())
	if err := q.Err(); err != nil {
		log.Fatalf("cannot round-trip path %q: %v", p.String(), err)
	}
}

What did you expect to see?

A passing test: an index is a perfectly valid thing to have as the first element of a path.

What did you see instead?

> exec go mod tidy
> exec go run .
[stderr]
main.go:16: cannot round-trip path "[2]": invalid label [2] 
exit status 1
[exit status 1]
FAIL: /tmp/y.txtar:2: unexpected command failure

rogpeppe avatar Sep 27 '24 12:09 rogpeppe