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" with 0.3.0-alpha3, not in 0.2.2 #539

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

"field not allowed" with 0.3.0-alpha3, not in 0.2.2 #539

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

Comments

@cueckoo
Copy link
Collaborator

cueckoo commented Jul 3, 2021

Originally opened by @shykes in cuelang/cue#539

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

0.3.0-alpha3

Does this issue reproduce with the latest release?

  • Latest stable release: no
  • Latest alpha release: yes

What did you do?

$ cat repro.cue

#Schema: {
	...
}

Component: {
	hostname: string | *"localhost"

        // This inner definition causes unification to fail in 0.3.0-alpha3
	#foo: {
		hello: "world"
	}
}

hello: #Schema & Component

What did you expect to see?

$ cue-0.2.2 vet repro.cue
$ cue-0.3.0-alpha3 vet repro.cue
$

What did you see instead?

$ cue-0.2.2 vet repro.cue
$ cue-0.3.0-alpha3 vet repro.cue
hello.#foo: field `hello` not allowed:
    ./repro.cue:10:3
    ./repro.cue:14:8
$
@cueckoo cueckoo added NeedsFix roadmap/evaluator Specific tag for roadmap issue #338 labels Jul 3, 2021
@cueckoo cueckoo added this to the v0.3.0-evaluator-rewrite milestone Jul 3, 2021
@cueckoo cueckoo closed this as completed Jul 3, 2021
@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @mpvl in cuelang/cue#539 (comment)

Analysis: this is a side effect of a bug that allows #foo to match a .... This then, somewhat oddly, cascades onwards to disallowing help.

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @mpvl in cuelang/cue#539 (comment)

Related reading: cuelang/cue#543

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @mpvl in cuelang/cue#539 (comment)

This actually touches upon an ambiguity in the spec. Namely whether ... should open up a struct only for regular fields or also for definitions.

The spec also now also allows ...T for structs (not yet allowed by the parser). The semantics for this is similar to JSON Schema's additional constraints and has mainly been introduced to allow encoding that behavior of JSON Schema as well as to make this syntactical element consistent between lists and structs.

It is likely that regular fields and definitions within a struct serve different roles. So applying ...T to both seem unintuitive and likely undesirable. If that is the case, having ... apply to both seems inconsistent.

Currently, this point is also moot, as definitions are allowed to be added in closed structs. But see #543. In that case, ... would have significance and I'm inclined to say that the spec should be clarified to have ... not apply to definitions.

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @mpvl in cuelang/cue#539 (comment)

This now works in tip.

I've not added an issue539.txtar file as this actually is invalid CUE as per the #543 proposal. For a discussion of this proposed change, please revert to that proposal Issue.

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