-
Notifications
You must be signed in to change notification settings - Fork 342
Description
Currently cue.Value.Err returns an error if any field that is part of the value is in error, even if some parts of the value are not in error and can be looked up without error.
I propose that there should be a way to make Err do less work and return an error only when the top level of the value (its scalar value or the set of fields) cannot be computed. Value.Validate could still be used to do a more thorough job.
Specifically, if Value.Err returns nil for some value v:
v.IncompleteKinddoes not return bottom- the fields of
vcan be iterated over without error if it's a struct - the indexes of
vcan be iterated over without error if it's a list
To avoid breaking compatibility, this behavior would be opt-in, either by providing an option when creating the cue.Context, or by providing an option when creating the value. What the spelling of this option is to be decided.
This change has a couple of significant advantages:
- it means that
Value.IncompleteKindbetter reflects the actual operations that can be done on the value. Currently even if it returnscue.Bottom, there are still some operations that are possible, but it's not easy to determine what those are. - it means that the implementation is free to use a more "compute-on-demand" implementation. Until the caller actually demands a value, the implementation can defer the computation necessary to provide it.