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: conflicting values in for loop with let expressions #3590

Closed
timspeetjens opened this issue Nov 25, 2024 · 5 comments
Closed

evaluator: conflicting values in for loop with let expressions #3590

timspeetjens opened this issue Nov 25, 2024 · 5 comments

Comments

@timspeetjens
Copy link

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

$ cue version
cue version v0.11.0

go version go1.23.3
      -buildmode exe
       -compiler gc
       -trimpath true
     CGO_ENABLED 0
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
cue.lang.version v0.11.0

Does this issue reproduce with the latest stable release?

Yes (0.11.0). 0.10.1 runs as expected

What did you do?

exec cue eval -c conflicting.cue
cmp stdout stdout.golden

-- conflicting.cue --
#Result: [_]: {[string]: string}

result: #Result

#Input: {
	p: "A" | "B"
}

_input: [Parm=_]: #Input & {
	p: Parm
}

_input: {
	A: {}
	B: {}
}

for _, v in _input {
	let Var1 = v.p
	let Var2 = Var1

	let Items = {
		"item": Var2
	}

	result: "conflicting-\(v.p)": Items
}
-- stdout.golden --
result: {
    "conflicting-A": {
        item: "A"
    }
    "conflicting-B": {
        item: "B"
    }
}

What did you expect to see?

Passing test

What did you see instead?

[stderr]
result."conflicting-A".item: conflicting values "B" and "A":
    ./conflicting.cue:10:5
    ./conflicting.cue:18:1
    ./conflicting.cue:19:13
    ./conflicting.cue:20:13
    ./conflicting.cue:23:11
    ./conflicting.cue:26:33
[exit status 1]
@timspeetjens
Copy link
Author

Bisected to 3965579

@timspeetjens
Copy link
Author

Would you be willing to revert 3965579 ? It appears to be a one-liner, not counting the additional test cases.

@PierreR
Copy link

PierreR commented Dec 3, 2024

I was able to reproduce this issue.
I believe it affects both the old and the new evaluator. Correct ?

@myitcv
Copy link
Member

myitcv commented Dec 6, 2024

@timspeetjens @PierreR - thanks for raising and looking into this. I can indeed confirm that 3965579 is the point at which this broke, with the slightly simpler reducer:

exec cue eval conflicting.cue
cmp stdout stdout.golden

-- conflicting.cue --
result: [_]: [string]: string

_input: {
	A: p: "A"
	B: p: "B"
}

for _, v in _input {
	let Var1 = v.p

	// Second let variable required here; just using Var1 with Items not
	// sufficient
	let Var2 = Var1

	let Items = {
		item: Var2
	}

	result: "conflicting-\(v.p)": Items
}
-- stdout.golden --
result: {
    "conflicting-A": {
        item: "A"
    }
    "conflicting-B": {
        item: "B"
    }
}

Marcel is deep debugging another issue right now, but I will mark this for the first alpha of v0.12.

@myitcv myitcv removed the Triage Requires triage/attention label Dec 6, 2024
@myitcv myitcv changed the title cue eval - conflicting values in for loop with let expressions evaluator: conflicting values in for loop with let expressions Dec 6, 2024
@github-project-automation github-project-automation bot moved this to Backlog in Release v0.12 Dec 6, 2024
@myitcv myitcv moved this from Backlog to v0.12.0-alpha.1 in Release v0.12 Dec 6, 2024
@myitcv
Copy link
Member

myitcv commented Dec 8, 2024

Apologies, I should have been clearer earlier; this affects both v2 and v3 of the evaluator.

@mvdan mvdan moved this from v0.12.0-alpha.1 to v0.12.0-alpha.2 in Release v0.12 Dec 16, 2024
cueckoo pushed a commit that referenced this issue Dec 23, 2024
The issue is a regression introduced in
https://cuelang.org/cl/1199752

Issue #3590
Issue #3591

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I1e2a9be08a7957b72c4904856f68af8f9efc3c45
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206278
Reviewed-by: Daniel Martí <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
@mvdan mvdan moved this from Backlog to v0.11.2 in Release v0.11 Dec 23, 2024
cueckoo pushed a commit that referenced this issue Dec 23, 2024
This only fixes the issue for V2: for v3 this causes
too many issues and another solution has to be found.

Note that of the tests only letjoin.txtar has material
changes. The changes in let.txtar reflect the behavior
in V2 from before the regression.
All other test changes are counter changes.

See the original regression:
https://cuelang.org/cl/1199752

Issue #3590
Issue #3591

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I9ff6496c37dbf21ca58861ee2906d82beaa82e62
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206279
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
cueckoo pushed a commit that referenced this issue Jan 22, 2025
The issue is a regression introduced in
https://cuelang.org/cl/1199752

Issue #3590
Issue #3591

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I1e2a9be08a7957b72c4904856f68af8f9efc3c45
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206278
Reviewed-by: Daniel Martí <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207622
Reviewed-by: Paul Jolly <[email protected]>
cueckoo pushed a commit that referenced this issue Jan 22, 2025
This only fixes the issue for V2: for v3 this causes
too many issues and another solution has to be found.

Note that of the tests only letjoin.txtar has material
changes. The changes in let.txtar reflect the behavior
in V2 from before the regression.
All other test changes are counter changes.

See the original regression:
https://cuelang.org/cl/1199752

Issue #3590
Issue #3591

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I9ff6496c37dbf21ca58861ee2906d82beaa82e62
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1206279
TryBot-Result: CUEcueckoo <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/1207623
Reviewed-by: Paul Jolly <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: v0.11.2
Status: v0.12.0-alpha.2
Development

No branches or pull requests

4 participants