Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

cue: implement occurs check #29

Closed
mpvl opened this issue Apr 5, 2019 · 2 comments
Closed

cue: implement occurs check #29

mpvl opened this issue Apr 5, 2019 · 2 comments
Labels
roadmap/errors Related to improving error messages. roadmap/evaluator Specific tag for roadmap issue #338

Comments

@mpvl
Copy link
Contributor

mpvl commented Apr 5, 2019

Referential cycles are currently implemented. Structural cycles are not, however. So CUE currently allows the definition of infinite structures like:

{ f: { a: f } }

As defined by the spec, infinite structures are not allowed. Infinite structures should be detected and disallowed using an occurs check, as is commonly done in graph unification implementations.

There are some design decisions to be made though. A careful choice of semantics in the occurs check could make CUE not Turing complete and even guarantee termination. This weakens the power of CUE, but may be a desirable property if CUE is to be used for things like smart contracts, where the ability to determine termination would be a major win.

For an example of Turing completeness in CUE see the test called "reentrance" in resolve_test.go, which implements Fibonacci in CUE. The specifics of the semantics of the occurs check will determine whether these shenanigans would be allowed or not.

Depending on the level of restrictions, it should be investigated whether the occurs check can be implemented cheaply using Tomabechi-style cycle detection.

@mpvl mpvl added this to the v0.0.1 milestone Apr 27, 2019
@mpvl mpvl modified the milestones: v0.0.1, v0.2.0 Jun 22, 2019
mpvl added a commit that referenced this issue Jul 1, 2019
This is a temporary workaround to not having an
occurs check. See Issue #29.

Change-Id: I2d6f3bfe3493322cf507e0088d415afaf97bda4f
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/2365
Reviewed-by: Marcel van Lohuizen <[email protected]>
@mpvl mpvl added roadmap/errors Related to improving error messages. roadmap/evaluator Specific tag for roadmap issue #338 labels Dec 1, 2019
@mpvl mpvl mentioned this issue Dec 22, 2019
mpvl added a commit that referenced this issue Jul 22, 2020
Issue #29
Issue #42

Change-Id: I86191d7bf4fdcf8705d740171aedd81e04819dd5
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6522
Reviewed-by: Marcel van Lohuizen <[email protected]>
@mpvl
Copy link
Contributor Author

mpvl commented Jul 26, 2020

Fixed in v0.3.0-alpha1. See https://github.com/cuelang/cue/blob/master/cue/testdata/cycle/structural.txtar for test cases.

@cueckoo
Copy link

cueckoo commented Jul 3, 2021

This issue has been migrated to cue-lang/cue#29.

For more details about CUE's migration to a new home, please see cue-lang/cue#1078.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
roadmap/errors Related to improving error messages. roadmap/evaluator Specific tag for roadmap issue #338
Projects
None yet
Development

No branches or pull requests

2 participants