Bolt icon indicating copy to clipboard operation
Bolt copied to clipboard

It should not be possible to create infinite datatypes

Open samvv opened this issue 2 years ago • 0 comments

Problem

Consider the following definition:

enum List a.
  Nil
  Pair a (List a)

Here, the recursive call to List a is wrapped in a Pair, which makes everything OK.

Imagine now the following type:

enum Node a.
  Ref (Node a)

Here, the datatype is clearly invalid because to instantiate it you would need an infinite sequence of Refs.

The compiler needs a check to prevent this from happening.

samvv avatar Jun 02 '23 18:06 samvv