Skip to content

cue/eval: list.Range fails inappropriately when called in definition #2175

@rogpeppe

Description

@rogpeppe

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

$ cue version
cue version v0.0.0-20221207090135-ccdac14a7cb8

       -compiler gc
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
             vcs git
    vcs.revision ccdac14a7cb8b8eda5a101d4ededadb2c579db33
        vcs.time 2022-12-07T09:01:35Z
    vcs.modified false

Does this issue reproduce with the latest release?

What did you do?

exec cue export x.cue
cmp stdout expect.json

-- x.cue --
package c

import "list"

#T: {
	p: [...]
	r: list.Range(len(p)-1, 0, -1)
}

t: #T
t: p: [1, 2]

-- expect.json --
{
    "t": {
        "p": [
            1,
            2
        ],
        "r": [
            1
        ]
    }
}

What did you expect to see?

A passing testscript test.

What did you see instead?

> exec cue export x.cue
[stderr]
#T.r: error in call to list.Range: end must be less than start when step is negative:
    ./x.cue:7:5
[exit status 1]
FAIL: /tmp/testscript4234227699/x.txtar/script.txtar:1: unexpected command failure

The argument to list.Range is treated as final even though it isn't being emitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions