Recursive type definitions are not parsed correctly
vzarytovskii opened this issue · 5 comments
I hope it's fine if I will be creating issues I've found (and will be trying fixing them) here.
Recursive types definition are resulting in errors when parsing types declared with and
type Maybe<'T> = | Just B<'T> | Nothing
and 'T maybe = Maybe<'T>
results in
type_definition [1, 0] - [2, 24]
type_abbrev_defn [1, 5] - [2, 24]
type_name [1, 5] - [1, 14]
identifier [1, 5] - [1, 10]
type_arguments [1, 10] - [1, 14]
type_argument_defn [1, 11] - [1, 13]
type_argument [1, 11] - [1, 13]
identifier [1, 12] - [1, 13]
ERROR [1, 15] - [2, 12]
ERROR [1, 17] - [2, 3]
union_type_cases [1, 17] - [1, 39]
union_type_case [1, 19] - [1, 23]
identifier [1, 19] - [1, 23]
ERROR [1, 24] - [1, 29]
ERROR [1, 24] - [1, 25]
ERROR [1, 27] - [1, 28]
union_type_case [1, 32] - [1, 39]
identifier [1, 32] - [1, 39]
type [2, 4] - [2, 12]
type [2, 4] - [2, 6]
type_argument [2, 4] - [2, 6]
identifier [2, 5] - [2, 6]
long_identifier [2, 7] - [2, 12]
identifier [2, 7] - [2, 12]
type [2, 15] - [2, 24]
long_identifier [2, 15] - [2, 20]
identifier [2, 15] - [2, 20]
type_attributes [2, 21] - [2, 23]
type_attribute [2, 21] - [2, 23]
type [2, 21] - [2, 23]
type_argument [2, 21] - [2, 23]
identifier [2, 22] - [2, 23]
Very nice @vzarytovskii!
We should consider adding these failing examples the corpus to ensure we don't regress in the future.
I will try to get it cleaned up such that the current tests doesn't fail.
Very nice @vzarytovskii Vlad Zarytovskii FTE! We should consider adding these failing examples the corpus to ensure we don't regress in the future. I will try to get it cleaned up such that the current tests doesn't fail.
Sure, give me some time, to figure out how corpus works :)
Come to think of it, is type Maybe<'T> = | Just B<'T> | Nothing
valid f#?
I've added the and
keyword for types in 275f3ca, but the union cases does not match the rules in the language specification
Come to think of it, is
type Maybe<'T> = | Just B<'T> | Nothing
valid f#?
It's a typo, apologies. B not supposed to be there but 'of' instead.
I've added the
and
keyword for types in 275f3ca, but the union cases does not match the rules in the language specification
So, it's working for
type A<'T> = | B of 'T
and C<'T> = A<'T>
But not for something like
type A<'T> = | B of 'T
and 'T C = A<'T>
(notice the prefix style type paramter)
Let me try fix it.
Update: the following type definition doesn't work either:
type 'T X = | Y of 'T