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 eval regression with evalv3 involving a comprehension and cyclic references #3621

Open
mvdan opened this issue Dec 11, 2024 · 0 comments
Labels
evaluator evalv3 issues affecting only the evaluator version 3

Comments

@mvdan
Copy link
Member

mvdan commented Dec 11, 2024

# With the old evaluator.
env CUE_EXPERIMENT=evalv3=0
exec cue eval
exec cue export

# With the new evaluator.
env CUE_EXPERIMENT=evalv3=1
exec cue eval
exec cue export

-- input.cue --
package p

hello: "world"
outer: [Name=string]: name: Name
if true {
	inner: inner2: {
		name:           "Employees"
		description:    "All employees"
		privacy:        "secret"
		create_default: false
	}
	outer: outer2: {
		bar: (inner.inner2.name)
	}
}

As of 0e99c20, the old evaluator evals and exports fine:

# With the old evaluator. (0.019s)
> env CUE_EXPERIMENT=evalv3=0
> exec cue eval
[stdout]
hello: "world"
inner: {
    inner2: {
        name:           "Employees"
        description:    "All employees"
        privacy:        "secret"
        create_default: false
    }
}
outer: {
    outer2: {
        bar:  "Employees"
        name: "outer2"
    }
}
> exec cue export
[stdout]
{
    "hello": "world",
    "inner": {
        "inner2": {
            "name": "Employees",
            "description": "All employees",
            "privacy": "secret",
            "create_default": false
        }
    },
    "outer": {
        "outer2": {
            "bar": "Employees",
            "name": "outer2"
        }
    }
}

However, the new evaluator first does something very weird - cue eval exits successfully without printing anything at all, not even the hello: "world". This seems like a hard bug; if something went wrong, something is swallowing the error.

> env CUE_EXPERIMENT=evalv3=1
> exec cue eval

Then the cue export does show us the cyclic reference errors.

> exec cue export
[stderr]
inner.inner2.create_default: cyclic reference to field inner2:
    ./input.cue:5:1
inner.inner2.description: cyclic reference to field inner2:
    ./input.cue:5:1
inner.inner2.name: cyclic reference to field inner2:
    ./input.cue:5:1
inner.inner2.privacy: cyclic reference to field inner2:
    ./input.cue:5:1

But why? evalv2 handled this input just fine. Moreover, just removing the if true comprehension to inline its contents as follows seems to resolve the cyclic reference errors, which seems like a bug:

hello: "world"
outer: [Name=string]: name: Name
inner: inner2: {
	name:           "Employees"
	description:    "All employees"
	privacy:        "secret"
	create_default: false
}
outer: outer2: {
	bar: (inner.inner2.name)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
evaluator evalv3 issues affecting only the evaluator version 3
Projects
None yet
Development

No branches or pull requests

1 participant