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

"field ... not allowed" error #483

Closed
cueckoo opened this issue Jul 3, 2021 · 0 comments
Closed

"field ... not allowed" error #483

cueckoo opened this issue Jul 3, 2021 · 0 comments
Labels
NeedsFix roadmap/evaluator Specific tag for roadmap issue #338

Comments

@cueckoo
Copy link
Collaborator

cueckoo commented Jul 3, 2021

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.)

@cueckoo cueckoo added NeedsFix roadmap/evaluator Specific tag for roadmap issue #338 labels Jul 3, 2021
@cueckoo cueckoo closed this as completed Jul 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix roadmap/evaluator Specific tag for roadmap issue #338
Projects
None yet
Development

No branches or pull requests

1 participant