-
Notifications
You must be signed in to change notification settings - Fork 292
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
Too early evaluation? #955
Comments
Original reply by @mpvl in cuelang/cue#955 (comment) 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. |
Original reply by @kumorid in cuelang/cue#955 (comment) 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 |
Originally opened by @kumorid in cuelang/cue#955
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: