Skip to content

cue: struct.MinFields causes inappropriate error #3867

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

Open
rogpeppe opened this issue Mar 31, 2025 · 0 comments
Open

cue: struct.MinFields causes inappropriate error #3867

rogpeppe opened this issue Mar 31, 2025 · 0 comments

Comments

@rogpeppe
Copy link
Member

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

$ cue version
72567b93ca6309a865fd45a3ffe14f9957134a25

Does this issue reproduce with the latest stable release?

v0.13.0-alpha.3

What did you do?

exec go mod tidy
exec go run .
cmp stdout want-stdout

-- want-stdout --
struct
<nil>
-- go.mod --
module tstcue

go 1.23.0

require (
	cuelang.org/go v0.13.0-alpha.3
	github.com/go-quicktest/qt v1.101.0
)

-- main.go --
package main

import (
	"fmt"

	"cuelang.org/go/cue/cuecontext"
)

func main() {
	ctx := cuecontext.New()
	v := ctx.CompileString(`
import "struct"
{x?: bool} & struct.MinFields(1)
`)
	fmt.Println(v.IncompleteKind())
	fmt.Println(v.Err())
}

What did you expect to see?

A passing test. Adding a MinFields constraint that may be satisfied later should not cause IncompleteKind to return bottom.

This behaviour means it's not possible to inspect such incomplete values to see what kind they might be, which hinders tooling.

What did you see instead?

> exec go mod tidy
> exec go run .
[stdout]
_|_
invalid value {x?:bool} (does not satisfy struct.MinFields(1)): len(fields) < MinFields(1) (0 < 1)
> cmp stdout want-stdout
diff stdout want-stdout
--- stdout
+++ want-stdout
@@ -1,2 +1,2 @@
-_|_
-invalid value {x?:bool} (does not satisfy struct.MinFields(1)): len(fields) < MinFields(1) (0 < 1)
+struct
+<nil>

FAIL: /tmp/x.txtar:4: stdout and want-stdout differ
@rogpeppe rogpeppe added NeedsInvestigation Triage Requires triage/attention NeedsFix evaluator and removed NeedsInvestigation Triage Requires triage/attention labels Mar 31, 2025
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