qwertie / ecsharp

Home of LoycCore, the LES language of Loyc trees, the Enhanced C# parser, the LeMP macro preprocessor, and the LLLPG parser generator.
http://ecsharp.net
Other
172 stars 25 forks source link

Ref locals cannot have parentheses #131

Closed qwertie closed 3 years ago

qwertie commented 3 years ago

Having not used the "ref local" feature myself, I glossed over the fact that it requires ref on the right side of the assignment operator:

ref var x = ref y;
x = ref y;

EC# allows ref (and any other attribute-keyword) on any expression, but if it is not at the beginning of the expression, the subexpression must be in parentheses:

ref var x = (ref y);
x = (ref y);

Unfortunately, C# rejects the latter code, so it will be necessary to modify the parser and printer to support ref without parens.