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

spec/cycles/Structural_cycles: optional field bug? #145

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

spec/cycles/Structural_cycles: optional field bug? #145

cueckoo opened this issue Jul 3, 2021 · 3 comments
Labels

Comments

@cueckoo
Copy link
Collaborator

cueckoo commented Jul 3, 2021

Originally opened by @rudolph9 in cuelang/cue#145

spec/cycles/Structural_cycles

Arguably the following falls under the category of

It is allowed for a value to define an infinite set of possibilities without evaluating to an infinite structure itself.

Foo: {
  foo?: Foo
  bar: string
}

foo: Foo & {
  foo:{ 
    bar: "barNested"
  }
  bar: "barParent"
}

but in the current version of cue it doesn't return (probably eventually a stack overflow error but killed it after like 5 minutes).

$ cue eval optional_structural_cycle.cue
# waiting
# waiting
# waiting
^C

I could also see this fall under the category of an infinite cycle so could use some clarity around if it's a bug with the evaluation or if it just need some clarity in the doc and maybe make sure it's detected in the cycle check that will eventually be rolled cuelang/cue#29

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @rudolph9 in cuelang/cue#145 (comment)

This feature is relevant to a little testing package I'm working on refining, if supported it would allow me to infinitely nest describe scopes https://gist.github.com/rudolph9/eccc978e71fd9c32b0ae182ce6854c16

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

Original reply by @jlongtine in cuelang/cue#145 (comment)

You might try with the latest master. Marcel made some updates that I think might be relevant.

@cueckoo
Copy link
Collaborator Author

cueckoo commented Jul 3, 2021

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

I tested this does not work with the new version. This is indeed another case. The current implementation explicitly tests for disjunctions that allow such infinite structure. But optional fields implicitly such a disjunction. And as @rudolph9 correctly notes, the spec allows for such cases.

Note that none of this is related to evaluation, but merely to printing. The engine is happy to compute on infinite structures. It is just the representation of these infinite structures that is causing the trouble.

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

1 participant