cue-lang / cue

The home of the CUE language! Validate and define text-based and dynamic configuration
https://cuelang.org
Apache License 2.0
5.14k stars 294 forks source link

internal/core: treat certain unification errors as "incomplete" #1483

Open mpvl opened 2 years ago

mpvl commented 2 years ago

See also #1479

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

v0.4.1

What did you do?

cue def of

b: {...}
check: len(b) == 1

results in

b: {...}
check: len(b) == 1

This is correct, as the number of elements in b might change as the schema gets more concrete.

Similarly, cue def of

b: {...}
check: len(b) == 1
check: true

should result in an unchanged configuration.

Instead it results in

check: conflicting values true and false:
    -:2:5
    -:3:5

This is because CUE evaluates this as a "fatal" error (an error that cannot be solved by making a configuration more specific), even though it is not.

rogpeppe commented 2 years ago

Confirmed with commit dc2c9e0950f36895f819171cab447eb7b54758e0.

Testscript reproducer:

exec cue def x.cue
-- x.cue --
b: {...}
check: len(b) == 1
check: true