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: field not allowed #3331

Closed
uhthomas opened this issue Jul 26, 2024 · 3 comments
Closed

evalv3: field not allowed #3331

uhthomas opened this issue Jul 26, 2024 · 3 comments

Comments

@uhthomas
Copy link
Contributor

uhthomas commented Jul 26, 2024

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

$ go run cuelang.org/go/cmd/[email protected] version
cue version v0.10.0-alpha.2.0.20240726102249-5de5b42c834f

go version go1.22.5
      -buildmode exe
       -compiler gc
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
cue.lang.version v0.10.0

Does this issue reproduce with the latest stable release?

What did you do?

import "list"

#A: {
	let b = {}

	c: b & {
		d: 1
	}
}

list.Concat([[#A]])

What did you expect to see?

$ go run cuelang.org/go/cmd/[email protected] export ./a.cue
[
    {
        "c": {
            "d": 1
        }
    }
]

What did you see instead?

$ CUE_EXPERIMENT=evalv3 go run cuelang.org/go/cmd/[email protected]
0.0.c.d: field not allowed:
    ./a.cue:6:5
    ./a.cue:7:3
exit status 1
@uhthomas
Copy link
Contributor Author

Really bizarre. This fails:

import "list"

#A: {
	let b = {}

	c: #B & b & {
		d: 1
	}
}

#B: d: int

list.Concat([[#A]])

This doesn't:

import "list"

#A: {
	c: #B & {
		d: 1
	}
}

#B: d: int

list.Concat([[#A]])

This is also okay:

import "list"

#A: {
	c: #B & {} & {
		d: 1
	}
}

#B: d: int

list.Concat([[#A]])

@uhthomas
Copy link
Contributor Author

uhthomas commented Jul 26, 2024

this is okay though.

import "list"

#A: {
	let b = #B & {}

	c: b & {
		d: 1
	}
}

#B: d: int

list.Concat([[#A]])

@mvdan mvdan added evaluator and removed Triage Requires triage/attention labels Jul 29, 2024
@mpvl
Copy link
Member

mpvl commented Aug 5, 2024

Analysis: Similar to #3330. Normally referencing a struct within a definition does not affect closeness. In other words, this is allowed according to the spec:

#A: {
   b: c: int
   d: b
   d: e: int
}

Referencing in #A seems to trigger a different behavior in some cases, so that a reference like b treats it as closed.

cueckoo pushed a commit that referenced this issue Aug 12, 2024
Issue #3325
Issue #3330
Issue #3331

Signed-off-by: Marcel van Lohuizen <[email protected]>
Change-Id: I16c3639fb016020ea58b75e7ecefa0fc1d1afe84
Reviewed-on: https://cue.gerrithub.io/c/cue-lang/cue/+/1199271
Reviewed-by: Matthew Sackman <[email protected]>
Reviewed-by: Daniel Martí <[email protected]>
Unity-Result: CUE porcuepine <[email protected]>
TryBot-Result: CUEcueckoo <[email protected]>
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

3 participants