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: unexpected behaviour from list.Sum #3541

Open
de-odex opened this issue Oct 30, 2024 · 3 comments
Open

evaluator: unexpected behaviour from list.Sum #3541

de-odex opened this issue Oct 30, 2024 · 3 comments
Assignees

Comments

@de-odex
Copy link

de-odex commented Oct 30, 2024

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

$ cue version
cue version v0.10.1

go version go1.23.2
      -buildmode exe
       -compiler gc
       -trimpath true
     CGO_ENABLED 0
          GOARCH amd64
            GOOS windows
         GOAMD64 v1
cue.lang.version v0.10.1

Does this issue reproduce with the latest stable release?

Yes. Tested in playground as of today.

What did you do?

import "list"

_test: {
  one: {
    num: 2
    test: num: 6
  }
  two: {
    num: 3
    test: num: 7
  } 
  three: {
    num: 4
    test: num: 8
  } 
  four: {
    num: 5
    test: num: 9
  }
}

list.Sum([for key, val in _test {
  val.num + val.test
}])

Evaluate this.

What did you expect to see?

Invalid operands error (int and struct)

What did you see instead?

Evaluates to 0

@de-odex de-odex added NeedsInvestigation Triage Requires triage/attention labels Oct 30, 2024
@de-odex de-odex changed the title unexpected behaviour from list.Sum evaluator: unexpected behaviour from list.Sum Oct 30, 2024
@de-odex
Copy link
Author

de-odex commented Oct 30, 2024

works in evalv3, perhaps a non-issue

@de-odex de-odex closed this as completed Oct 30, 2024
@de-odex
Copy link
Author

de-odex commented Oct 30, 2024

perhaps it is better to leave it to your discretion whether to close this as a non-issue or not

@de-odex de-odex reopened this Oct 30, 2024
@mvdan
Copy link
Member

mvdan commented Oct 31, 2024

Thanks for reporting - good to hear that evalv3 fixes this issue. We will add a regression test to ensure our test suite covers this edge case.

@mvdan mvdan self-assigned this Oct 31, 2024
@mvdan mvdan removed the Triage Requires triage/attention label Nov 1, 2024
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

2 participants