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: logical operator ! should not be allowed on a disjunction #2656

Open
myitcv opened this issue Oct 25, 2023 · 1 comment
Open

evaluator: logical operator ! should not be allowed on a disjunction #2656

myitcv opened this issue Oct 25, 2023 · 1 comment

Comments

@myitcv
Copy link
Member

myitcv commented Oct 25, 2023

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

$ cue version
cue version v0.0.0-20231020094642-eddccfc72316

go version go1.21.3
      -buildmode exe
       -compiler gc
  DefaultGODEBUG panicnil=1
     CGO_ENABLED 1
          GOARCH arm64
            GOOS linux
             vcs git
    vcs.revision eddccfc72316a648971d9684ac5dcd003ee26385
        vcs.time 2023-10-20T09:46:42Z
    vcs.modified false

Does this issue reproduce with the latest release?

Yes

What did you do?

! exec cue eval x1.cue
cmp stderr stderr.golden

! exec cue eval x2.cue
stderr 'invalid operation'

-- x1.cue --
x: ! (4)

-- x2.cue --
x: ! (4 | 5)

-- stderr.golden --
x: invalid operation !4 (! int):
    ./x1.cue:1:4

What did you expect to see?

Passing test

What did you see instead?

> ! exec cue eval x1.cue
[stderr]
x: invalid operation !4 (! int):
    ./x1.cue:1:4
[exit status 1]
> cmp stderr stderr.golden
> ! exec cue eval x2.cue
[stdout]
x: !(4 | 5)
FAIL: /tmp/testscript2702638972/repro.txtar/script.txtar:4: unexpected command success

The intent here was to use ! as if we had implemented not().

We should disallow the use of ! in this way, ahead of introducing not().

@rogpeppe
Copy link
Member

As another data point, ! bool correctly fails:

x: invalid operand bool ('!' requires concrete value):

but ! (true | false) (exactly equivalent AIUI) does not.

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

2 participants