Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cue: Iterator.Selector regression since v0.6 added required fields #2692

Closed
mvdan opened this issue Nov 13, 2023 · 0 comments
Closed

cue: Iterator.Selector regression since v0.6 added required fields #2692

mvdan opened this issue Nov 13, 2023 · 0 comments

Comments

@mvdan
Copy link
Member

mvdan commented Nov 13, 2023

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

$ cue version
cue version v0.6.1-0.20231110172618-7a4ea8668a03

go version devel go1.22-8da6405e0d Sat Nov 11 02:02:35 2023 +0000
      -buildmode exe
       -compiler gc
        -ldflags -w -s
  DefaultGODEBUG httplaxcontentlength=1,httpmuxgo121=1,panicnil=1
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v3

Does this issue reproduce with the latest stable release?

Yes; verified with v0.6.0 as well as master as of 8f796bf.

What did you do?

go mod tidy

go run main.go
cmp stderr stderr.golden
-- main.go --
package main

import "cuelang.org/go/cue/cuecontext"

func main() {
	val := cuecontext.New().CompileString(`[{name: "Bob"}]`)
	iter, err := val.List()
	if err != nil {
		panic(err)
	}
	for iter.Next() {
		println(iter.Selector().Index())
	}
}
-- stderr.golden --
0
-- go.mod --
module test

go 1.21

require cuelang.org/go v0.6.0

What did you expect to see?

Success, like with v0.5.0.

What did you see instead?

> go run main.go
[stderr]
panic: Index called on non-index selector

goroutine 1 [running]:
panic({0x90d7e0?, 0xa80610?})
	/home/mvdan/tip/src/runtime/panic.go:772 +0x158 fp=0xc00002fdc8 sp=0xc00002fd18 pc=0x43a2f8
cuelang.org/go/cue.Selector.Index({{0xa86f50?, 0xc00000e7b0?}})
	$WORK/.gopath/pkg/mod/cuelang.org/[email protected]/cue/path.go:205 +0x45 fp=0xc00002fde8 sp=0xc00002fdc8 pc=0x6d2f65
main.main()
	$WORK/main.go:12 +0x10c fp=0xc00002ff50 sp=0xc00002fde8 pc=0x8d85ec
runtime.main()
	/home/mvdan/tip/src/runtime/proc.go:271 +0x29d fp=0xc00002ffe0 sp=0xc00002ff50 pc=0x43d91d
runtime.goexit({})
	/home/mvdan/tip/src/runtime/asm_amd64.s:1694 +0x1 fp=0xc00002ffe8 sp=0xc00002ffe0 pc=0x46cf21

I bisected this to https://review.gerrithub.io/c/cue-lang/cue/+/552171, which tweaked selectors for required fields.

Thanks to @alecholmez and @jack-bischoff for helping uncover this regression.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant