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

cmd/cue: regression: comprehension value must be struct, found *ast.StructLit #473

Closed
cueckoo opened this issue Jul 3, 2021 · 1 comment

Comments

@cueckoo
Copy link
Collaborator

cueckoo commented Jul 3, 2021

Originally opened by @myitcv in cuelang/cue#473

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

$ cue version
cue version +304b02e linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

-- cue.mod/module.cue --
module: "mod.com"
-- x.cue --
package x

#Guide: {
        Terminals: [string]: #Terminal

        Steps: [string]: #Step

        #TerminalName: or([ for k, _ in Terminals {k}])

        #Step: {
                Terminal: #TerminalName
                Cmd:      string
        }

        #Terminal: {
                Image: string
        }
}

g: #Guide & {
        Terminals: client: {
                Image: "golang"
        }

        Steps: {
                list: {
                        Terminal: "client"
                        Cmd:      "ls"
                }
        }
}

Run:

cue eval --out json

What did you expect to see?

JSON output.

What did you see instead?

Error:

#Guide.#TerminalName.for[]: comprehension value must be struct, found *ast.StructLit

Compare with v0.2.2 which does correctly output the JSON representation.

With 304b02e the --out json flag does work if you add -c:

$ cue eval -c --out json
{
    "g": {
        "Terminals": {
            "client": {
                "Image": "golang"
            }
        },
        "Steps": {
            "list": {
                "Terminal": "client",
                "Cmd": "ls"
            }
        }
    }
}
@cueckoo cueckoo added this to the v0.3.0-evaluator-rewrite milestone Jul 3, 2021
@cueckoo cueckoo closed this as completed Jul 3, 2021
@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @mpvl in cuelang/cue#473 (comment)

For documentation purposes: this turns out to be an export bug!!! What happens with the --out mode is that it triggers several translation steps exporting to and from CUE and then to JSON. The cause is a bug in the exporter, which caused the reading back to fail.

The back and forth should probably be eliminated as well.

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