boltlang / Bolt

A programming language for rapid application development
35 stars 1 forks source link

It should not be possible to create infinite datatypes #48

Open samvv opened 1 year ago

samvv commented 1 year ago

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.