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

evaluator: should close() distribute across elements of a disjunction? #1917

Closed
myitcv opened this issue Sep 9, 2022 · 3 comments
Closed
Labels
NeedsInvestigation x/user/KubeVela Experimental CUE-user-based labels

Comments

@myitcv
Copy link
Member

myitcv commented Sep 9, 2022

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

$ cue version
cue version v0.0.0-20220905100514-9e9786e93b63

       -compiler gc
     CGO_ENABLED 1
          GOARCH arm64
            GOOS linux
             vcs git
    vcs.revision 9e9786e93b63af979d9f105a12c8519a6216e56f
        vcs.time 2022-09-05T10:05:14Z
    vcs.modified false

Does this issue reproduce with the latest release?

Yes

What did you do?

exec cue eval x.cue
cmp stdout stdout.golden

-- x.cue --
x: close({name: string}) | close({age: int})
x: name: "test"

y: close({name: string} | {age: int})
y: name: "test"
-- stdout.golden --
x: {
    name: "test"
}
y: {
    name: "test"
}

Playground link

What did you expect to see?

Passing test.

What did you see instead?

> exec cue eval x.cue
[stdout]
x: {
    name: "test"
}
y: close({
    name: string
} | {
    age: int
}) & {
    name: "test"
}
> cmp stdout stdout.golden
--- stdout
+++ stdout.golden
@@ -1,10 +1,6 @@
 x: {
     name: "test"
 }
-y: close({
-    name: string
-} | {
-    age: int
-}) & {
+y: {
     name: "test"
 }

FAIL: /tmp/testscript3032515904/repro.txtar/script.txtar:2: stdout and stdout.golden differ
@myitcv
Copy link
Member Author

myitcv commented Sep 9, 2022

cc @wonderflow @FogDong @Somefive based on our conversation earlier.

@myitcv myitcv added the x/user/KubeVela Experimental CUE-user-based labels label Sep 9, 2022
@myitcv
Copy link
Member Author

myitcv commented Sep 9, 2022

Noting in passing that numexists() as proposed in #943 addresses one of the core use-cases of using close() in this way, namely one-of semantics.

@myitcv
Copy link
Member Author

myitcv commented Oct 6, 2022

Closing per #1878 (comment). The use case behind this question is better solved with oneof semantics. So closing this issue in the absence of something concrete to motivate changing the existing semantics.

@myitcv myitcv closed this as completed Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation x/user/KubeVela Experimental CUE-user-based labels
Projects
None yet
Development

No branches or pull requests

1 participant