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

evalv3: regression in API with disjunction containing closed struct #3562

Open
rogpeppe opened this issue Nov 7, 2024 · 1 comment
Open

Comments

@rogpeppe
Copy link
Member

rogpeppe commented Nov 7, 2024

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

v0.11.0-alpha.5

Does this issue reproduce with the latest stable release?

Yes (v0.10.0)

What did you do?

exec go mod tidy
! exec go run .

env CUE_EXPERIMENT=evalv3
! exec go run .

-- go.mod --
module test
require cuelang.org/go v0.11.0-alpha.5
-- main.go --
package main

import (
	"log"

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

func main() {
	ctx := cuecontext.New()
        // Make sure script works with earlier CUE versions prior to https://review.gerrithub.io/c/cue-lang/cue/+/1202685
	if os.Getenv("CUE_EXPERIMENT") == "evalv3" {
		ctx = cuecontext.New(cuecontext.EvaluatorVersion(cuecontext.EvalV3))
	}
	a := ctx.CompileString(`null | close({a?: _})`)
	b := ctx.CompileString(`quux: "boom"`)
	err := a.Unify(b).Validate()
	if err != nil {
		log.Fatal(err)
	}
}

What did you expect to see?

Passing test. Both evalv2 and evalv3 should both fail to validate this example.

What did you see instead?

> exec go mod tidy
> ! exec go run .
[stderr]
main.go:15: 2 errors in empty disjunction: (and 2 more errors)
exit status 1
[exit status 1]
> env CUE_EXPERIMENT=evalv3
> ! exec go run .
FAIL: /tmp/x.txtar:5: unexpected command success
@rogpeppe
Copy link
Member Author

rogpeppe commented Nov 7, 2024

Here's another failure, quite possibly related. Again I couldn't get this to fail in a single CUE file example:

exec go mod tidy
exec go run .

env CUE_EXPERIMENT=evalv3
exec go run .

-- go.mod --
module test
require cuelang.org/go v0.11.0-alpha.5

-- main.go --
package main

import (
	"log"
	"os"

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

func main() {
	ctx := cuecontext.New()
	if os.Getenv("CUE_EXPERIMENT") == "evalv3" {
		ctx = cuecontext.New(cuecontext.EvaluatorVersion(cuecontext.EvalV3))
	}
	a := ctx.CompileString(`close({{[=~"a"]: _}})`)
	b := ctx.CompileString(`"a": 1`)
	err := a.Unify(b).Validate()
	if err != nil {
		log.Fatal(err)
	}
}

The failure I see is:

> exec go mod tidy
> exec go run .
> env CUE_EXPERIMENT=evalv3
> exec go run .
[stderr]
main.go:19: field not allowed: a
exit status 1
[exit status 1]
FAIL: /tmp/x.txtar:5: unexpected command failure

Note: if I remove the redundant braces inside the close call, I don't see the failure.

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

No branches or pull requests

1 participant