Skip to content

"field ... not allowed" error #483

Closed
@cueckoo

Description

@cueckoo

Originally opened by @powerduncan in cuelang/cue#483

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

$ cue version
cue version 0.3.0-alpha1 darwin/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

$ cat error.cue
out: {
        instance
}
instance: #Type & {
        alpha: bravo: charlie: true
}
#Type: #Root & {
        alpha?: bravo?: charlie?: bool
}
#Root: { ... }

$ cue eval error.cue
out.alpha.bravo: field `charlie` not allowed:
    ./error.cue:5:9
    ./error.cue:5:16
    ./error.cue:8:10
    ./error.cue:8:18

What did you expect to see?

No error...

What did you see instead?

field `charlie` not allowed`

Changes from the example above that result in completely unexplained success:

  • Removing out: { instance }
  • Changing out to simply out: instance (rather than using an embedding)
  • Removing any of alpha, bravo, and charlie (overkill, sure, but just to be safe, I checked the removal of each independently, keeping the rest of the sequence intact: alpha?: bravo?: bool, alpha?: charlie?: bool, etc.)

I have identified two other changes that also result in a successful evaluation. I understand these both to eliminate the effect of the "closed-ness" of #Root, but that doesn't quite make sense to me as I thought that ... was supposed to keep the struct open.

  • Changing #Root to Root
  • Embedding #Root, instead of unifying with it (i.e., #Type: { #Root, alpha?: ... })

Interestingly, adding delta to the chain (alpha?: bravo?: charlie?: delta?: bool, etc.), changes the error slightly:

$ cue eval error.cue
out.alpha.bravo: field `charlie` not allowed:
    ./error.cue:5:9
    ./error.cue:5:16
    ./error.cue:8:10
    ./error.cue:8:18
out.alpha.bravo.charlie: field `delta` not allowed:
    ./error.cue:5:16
    ./error.cue:5:25
    ./error.cue:8:18
    ./error.cue:8:28

(Converted from discussion thread at the behest of @myitcv.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions