Open AjaiKN opened 1 year ago
Thanks for reporting this @Aurelius333, I don't think we allow recursive definitions like this:
Term : [
Foo,
Bar Term,
]
But the error message should be improved of course.
I'm a little confused because I've been writing programs the last couple days that rely extensively on recursive tag unions, and mostly, they've worked well. It's only in this specific case (when I write a when
expression structured as above with the if
s) that it hasn't worked.
It also says in roc-for-elm-programmers.md that recursive tag unions are allowed:
You can also use tags to define recursive data structures, because recursive type aliases are allowed as long as the recursion happens within a tag. For example:
LinkedList a : [Nil, Cons a (LinkedList a)]
Inferred recursive tags use the
as
keyword. For example, the inferred version of the above type alias would be:
[Nil, Cons a b] as b
Oh you're right, I'm sorry. I'll tag @ayazhafiz for follow-up.