This repository has been archived by the owner on Nov 18, 2021. It is now read-only.
cue: implement occurs check #29
Labels
roadmap/errors
Related to improving error messages.
roadmap/evaluator
Specific tag for roadmap issue #338
Milestone
Referential cycles are currently implemented. Structural cycles are not, however. So CUE currently allows the definition of infinite structures like:
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.
The text was updated successfully, but these errors were encountered: