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: strange behaviour with chaining of list comprehensions #3124

Open
myitcv opened this issue May 8, 2024 · 0 comments
Open

evalv3: strange behaviour with chaining of list comprehensions #3124

myitcv opened this issue May 8, 2024 · 0 comments

Comments

@myitcv
Copy link
Member

myitcv commented May 8, 2024

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

$ cue version
cue version v0.0.0-20240507175810-9efad9041981

go version go1.22.1
      -buildmode exe
       -compiler gc
  DefaultGODEBUG httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
     CGO_ENABLED 1
          GOARCH arm64
            GOOS linux
             vcs git
    vcs.revision 9efad90419811c9a27682857ffdc9324cdb7e094
        vcs.time 2024-05-07T17:58:10Z
    vcs.modified false
cue.lang.version v0.9.0

Does this issue reproduce with the latest release?

Yes

What did you do?

# old evaluator
env CUE_EXPERIMENT=''
exec cue export x.cue
cmp stdout stdout.golden

# new evaluator
env CUE_EXPERIMENT='evalv3'
exec cue export x.cue
cmp stdout stdout.golden

-- x.cue --
import "math/bits"

x: [...bool]
x: [true, false, true, true]
y: [for _, v in x {[if v {1}, 0][0]}]
z: [for i, v in y {bits.Set(*z[i-1] | 0, len(y)-i-1, v)}][3]

-- stdout.golden --
{
    "x": [
        true,
        false,
        true,
        true
    ],
    "y": [
        1,
        0,
        1,
        1
    ],
    "z": 1
}

What did you expect to see?

Passing test.

What did you see instead?

# old evaluator (0.012s)
# new evaluator (0.011s)
> env CUE_EXPERIMENT='evalv3'
> exec cue export x.cue
[stderr]
z: error in call to math/bits.Set: non-concrete value _:
    ./x.cue:6:20
[exit status 1]
FAIL: /tmp/testscript820382168/repro.txtar/script.txtar:8: unexpected command failure

Note that it is understood that the reference in the declaration of z to *z[i-1] | 0 is "wrong" by virtue of the result of z being a scalar value (contrast https://cuelang.org/play/?id=MSdriK7Ernf#w=function&i=cue&f=eval&o=cue) but reporting this actual error for completeness' sake.

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