Skip to content

cue vet could be more helpful for incomplete comprehension conditions #4249

@rogpeppe

Description

@rogpeppe

Consider the following example:

! exec cue vet -c=false x.cue

-- x.cue --
#Y: {
	cond!: bool
	x!: int
}

y: #Y & {
	cond!: bool
	if cond {
		x: "hello"
	}
	if !cond {
		x: "blah"
	}
}

In this example, y represents a template where the condition is not known yet.
Whatever the condition, the result will always be a conflict, because in all cases, the CUE is setting x to a string where it's defined in the schema as an integer.

If this pattern occurs in real-world CUE, it would almost certainly be a mistake that we'd like to catch early.
However cue vet currently succeeds on this example.

I think it would be useful if cue vet was to fail if there is a conflict of this kind - theoretically we know that y is unified with #Y and that the field #Y.x is an int, so any occurrence of x that doesn't unify with int is a likely mistake. That way we could catch more failures early, even in the presence of incomplete results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureRequestNew feature or requestvetcandidate for a vet rule to detect suspect usage

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions