Improve type parsing
tamasvajk opened this issue · 2 comments
Type parsing doesn't seem to handle all the possible cases that can come up in C#.
-
One particular case which is missing is
void*
.void
is handled separately from all other types, and is only introduced as a return type, but that means that pointer types don't covervoid
.void*
,void**
, ... can show up anywhere a type can show up, not just as a return type. I thing it would be the most elegant ifvoid
could be added topredefined_type
as it is done in Roslyn. -
Similarly, it feels like shortcuts were made for ref types too. #246 allows
ref (readonly)
in delegate declarations, but that fix seems more like a workaround than a proper fix. For example in the below C# example, I thinkref
and the secondreadonly
should actually belong to thetype
and not thefield_declaration
.
ref struct X {
public X(){}
readonly ref readonly int x = 5;
}
produces
...
field_declaration [2, 4] - [2, 36]
modifier [2, 4] - [2, 12]
modifier [2, 13] - [2, 16]
modifier [2, 17] - [2, 25]
variable_declaration [2, 26] - [2, 35]
type: predefined_type [2, 26] - [2, 29]
variable_declarator [2, 30] - [2, 35]
...
Yeah I started adding ref_type - we have an unused stub for it - but adding it to the parser just exploded a whole bunch of conflicts so it was set aside as it wasn't a common pattern. We definitely have some precedent issues that I think are all tied together.
The two problems mentioned above have been solved.