Skip to content
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

evaluator: a disjunction of a struct with an interpolation error and a struct with an empty string remains not concrete #1445

Open
bttk opened this issue Jan 1, 2022 · 2 comments
Labels

Comments

@bttk
Copy link

bttk commented Jan 1, 2022

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

Playground v0.4.0

Does this issue reproduce with the latest release?

yes

What did you do?

let fn = {
    in: {
        content: string
        ch:      string | *"-"
    }
    out: "\(in.ch)\(in.content)\(in.ch)"
} | {
    in: content: null
    out: ""
}

let outer = {inner: string | *null }

let x = (fn & {in: content: outer.inner}).out
ox: "\(x)"
oy: "\((fn & {in: content: null}).out)"
oz: "\((fn & {in: content: "b"}).out)"

What did you expect to see?

In ox, the interpolation in the first part of fn is not possible, so I'd expect it to result in a concrete value.

ox: ""
oy: ""
oz: "-b-"

What did you see instead?

invalid interpolation: invalid interpolation: unresolved disjunction

let fn = {
	in: {
		content: string
		ch:      string | *"-"
	}
	out: "\(in.ch)\(in.content)\(in.ch)"
} | {
	in: {
		content: null
	}
	out: ""
}
let outer = {
	inner: string | *null
}
let x = (fn & {
	in: {
		content: outer.inner
	}
}).out
ox: "\(x)"
oy: ""
oz: "-b-"
@bttk bttk added NeedsInvestigation Triage Requires triage/attention labels Jan 1, 2022
@mpvl
Copy link
Member

mpvl commented Jan 11, 2022

Analysis: CUE normally eliminates erroneous disjuncts. It somehow does not seem to do that for interpolations (probably as it gobbles the error).

Regarding oy, the spec also needs clarification on how to handle null in interpolation.

@myitcv
Copy link
Member

myitcv commented Jan 13, 2022

Drive-by observation: the playground (where this behaviour was observed) by default behaves more like cue eval:

exec cue eval x.cue
-- x.cue --
let fn = {
    in: {
        content: string
        ch:      string | *"-"
    }
    out: "\(in.ch)\(in.content)\(in.ch)"
} | {
    in: content: null
    out: ""
}

let outer = {inner: string | *null }

let x = (fn & {in: content: outer.inner}).out
ox: "\(x)"
oy: "\((fn & {in: content: null}).out)"
oz: "\((fn & {in: content: "b"}).out)"

Hence why we are likely not surfacing an error in this situation (if, that is, there should be one).

Drive-by question:

CUE normally eliminates erroneous disjuncts

Is this an erroneous disjunct though? Or just one that is incomplete? Given what we're looking at here is cue eval like behaviour, I don't think this can be an erroneous disjunct. But under #822 and the changes discussed there regarding cue export I can see a world in which this would export.

@myitcv myitcv changed the title a disjunction of a struct with an interpolation error and a struct with an empty string remains not concrete evaluator: a disjunction of a struct with an interpolation error and a struct with an empty string remains not concrete Dec 21, 2022
@myitcv myitcv added the zGarden label Jun 15, 2023
@mvdan mvdan removed the zGarden label Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants