-
Notifications
You must be signed in to change notification settings - Fork 302
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
cue: Value.Expr loses default information #1710
Comments
i had thought it was a bug initially, too. But from comments like this one, i drew the conclusion that it's more of a suboptimal compromise taken on the way to a better, eventual goal. (And the way defaults are peeled off here suggested to me it's not an accident, at least?) I did come to the conclusion that this is actually very helpful behavior - tbqh, i've no idea how i would tease defaults out from non-default values without it. But it certainly was surprising, and i very much hope that when it's replaced with something better, i can still do what i need to do. Figuring all this out is one of the things that led me to write an expression tree printer. i plan to turn that into a standalone lib at some point soon, because no joke, after writing against the CUE Go API for more than a year, it's the thing that finally allowed me to work confidently with complex expressions encoded within |
Oh, since this issue is expressing "wat" re: I wrote this test and very sloppy analyzer to even begin to understand the varying behaviors (when is a list's default itself, or not itself? when is it considered open? when is it bottom- i note this here because i had no idea what to actually write down in an issue apart from "omg list exprs/defaults make my head hurt, what even makes sense?", which seems thematically in line with this issue |
To my mind, it feels like a lossy and serious continuity problem if I can't see from an
Please can you clarify with an example exactly what it is you are depending on, behaviour-wise?
Feels like this is worth raising a feature request, with a link to your code as a proof of concept/prototype?
I think it would be worth extracting that test to some plain CUE code which we can annotate with comments and analyse the behaviour of via |
It's possible to figure it out, but not from
Apologies, that was handwavy. The particular use case i had to cover was in cuetsy where references to values marked for export as a Typescript A: "foo" | "bar" @cuetsy(kind="enum") // declares an enum for export
B: {
Afield: A | *"bar" // allowed - specifies a default that's in the enum.
Abroken: A | *"baz" // not allowed, because "baz" isn't part of A's declaration of the enum
Aor: A | "baz" // allowed right now, "baz" just becomes a string literal in a union type with the exported enum
} @cuetsy(kind="interface")
This test illustrates output for similar cases that follow the rules (my test harness is still pretty crap so i'm not covering error cases well yet) I haven't finally and firmly landed on what the right approach is here, but clearly, any decision i make is predicated on being able to make precise distinctions between where in the expression tree a value comes from, whether it's a default, and whether that node in the tree is on the other side of a reference or not. That fine control - distinguishing between I probably have some other cases i've already forgotten about, too, but i think this one case illustrates the need well enough.
Sure! After trying many forms of this kind of dumper/debugger, this was really the first one that actually worked, in anger, to let me learn what was going on by doing. I'd love it if a wider audience could benefit from that.
👍
Definitely would be good to tease it apart. I did encounter some of ordering issues while writing that test, but i think the committed artifact was all independent of those. |
Not sure I follow the example (could well be missing something). For Using a disjunction introduces quite different semantics to https://cuelang.org/play/?id=vuhg1OWJXtb#cue@export@cue All the cases that are problems in that linked example result in Apologies if I've grabbed totally the wrong end of the stick here though. |
Hah! It totally does retain the disjunction. I may have tried that long ago, then just dismissed it out of hand as a possibility because, as your playground link notes, just naively looking at eval output of So yes, you're right, a conjunct is the semantics i actually want there. That'll certainly help both simplify implementation and allows for a cleaner expression of author intent. 🎉 🎉 I'll have to think if i have another case that clearly illustrates my need. I suspect that when i go in and update the cuetsy implementation to accommodate this helpful guidance you've provided here, i'll encounter another example. |
This is also a large part of my thinking/mindset behind why
Manifestation is literally one of the hardest things that I've come across since I started working with CUE. As @mpvl will also attest, it's also one of the biggest challenges in #822.
👍
Sounds great. Really happy to explore these sorts of things as GitHub discussions/similar. |
What version of CUE are you using (
cue version
)?Does this issue reproduce with the latest release?
Yes
What did you do?
What did you expect to see?
A passing test (although the exact format of the output is not the point of this issue).
What did you see instead?
It doesn't seem right that the expression returned by
cue.Value.Expr()
cannot explain the concrete value we decode from the samecue.Value
.The text was updated successfully, but these errors were encountered: