-
Notifications
You must be signed in to change notification settings - Fork 170
Too early evaluation? #955
Comments
In CUE, errors in definitions and hidden fields are also errors. In the definition, both To fix this, one could rewrite this as:
The builtins in proposal #943 give a bit more flexibility. In this case, one could write:
This approach would also allow specifying that at most one should be specified or any other combination of numbers. |
Yes, the proposal in #943 is what is needed. Agreed, much more terse and clear... However, I am not sure I completely understand your reasoning. Let me use a simpler example. -- test.cue -- #T: { a?: int isA: a != _|_ } d: #T & {a: 56} e: #T Running { "d": { "a": 56, "isa": true }, "e": { "isa": false } } That is, as All very intuitive and expected! However, if we instead of comparison operations perform unification operations, the rules seem to change! #T: { a?: int isA: a != _|_ valid: isA & true } d: #T & {a: 56} I would expect that given that Why does the evaluator jump the trigger so early in this case? I interpret this as an inconsistency when evaluating one operator (comparison) or the other (unification) Further proof of what I consider as inconsistent (imho). Consider the following struct: #T: { isa: bool valid: isa & true } d: #T & {a: 56} now, when running { "d": { "isa": true "valid": true } } To me the |
This issue has been migrated to cue-lang/cue#955. For more details about CUE's migration to a new home, please see cue-lang/cue#1078. |
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
I am trying to circumvent the problem reported in issue 951 by avoiding dijunctions of structs, opting for optional fields, but requiring exactly one of them to be provided.
The code I come up with is shown in file
test.cue
below.However, when executing
cue export test.cue
I get the error reported below.What did you expect to see?
What did you see instead?
It looks like field
_valid
is evaluated very early, resulting in bottom, provoking the error message.However, if instead of the above code I use the following (removed unification with
true
in_valid
):Then I get the expected result above. I.e,
_valid
is not computed early...The text was updated successfully, but these errors were encountered: