Skip to content

evalv3: empty disjunction regression involving let fields #3801

Closed
@mvdan

Description

@mvdan
# With the old evaluator.
env CUE_EXPERIMENT=evalv3=0
exec cue vet -c

# With the new evaluator.
env CUE_EXPERIMENT=evalv3=1
env CUE_DEBUG=openinline=0
exec cue vet -c

-- input.cue --
package p

#Resource: {
    someMsg: string
    obs: {} | *{missing: true}

    let pickMsg = [
        if obs.missing {msg: "\(someMsg)"},
        {msg: "bar"},
    ][0]
    patches: [{
        op:    "add"
        path:  "/metadata"
        value: pickMsg.msg
    }]
}

#Patches: [string]: _
#JSONPatch: {
    namespace?: string
    patch: [...#JSONOp]
    output: #Patches & {(namespace): patch}
}
#JSONOp: {
    op:    "add"
    path:  string
    value: _
} | {
    op:   "remove"
    path: string
}

#Main: {
    NS=namespace: string

    output: jsonPatch.output

    let jsonPatch = #JSONPatch & {
        let base = #Resource & {}
        let withMsg = base & {someMsg: "foo"}

        namespace: NS

        patch: withMsg.patches
    }
}
out: (#Main & {namespace: "ns1"}).output

As of 5d2da07, this gives:

# With the old evaluator. (0.010s)
> env CUE_EXPERIMENT=evalv3=0
> exec cue vet -c
# With the new evaluator. (0.047s)
> env CUE_EXPERIMENT=evalv3=1
> env CUE_DEBUG=openinline=0
> exec cue vet -c
[stderr]
jsonPatch.output.ns1.0: 2 errors in empty disjunction:
jsonPatch.output.ns1.0.op: conflicting values "remove" and "add":
    ./input.cue:12:16
    ./input.cue:29:11
jsonPatch.output.ns1.0.value: invalid interpolation: non-concrete value string (type string):
    ./input.cue:8:30
    ./input.cue:4:14
[exit status 1]

Reduced from @nyarly's project in Unity.

Metadata

Metadata

Assignees

Labels

evaluatorevalv3issues affecting only the evaluator version 3unity-winbugs found thanks to projects added to Unity

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions