-
Notifications
You must be signed in to change notification settings - Fork 92
Draft grammar to permit nullable types as array element types. #1297
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| array_type | ||
| : non_array_type rank_specifier+ | ||
| | non_array_type rank_specifier+ | ||
| | non_array_type ( nullable_type_annotation rank_specifier+ )+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this allow int??[]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, because a nullable type isn't a non_array_type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm reading it right, non_array_type includes value_type which includes nullable_value_type which I believe int? would be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd agree with @gafter. nullable_value_type is defined as non_nullable_value_type nullable_type_annotation. There's no additional condition for a nullable_value_type. So, int?? isn't a valid type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non_array_type may expand into value_type, which may expand into nullable_value_type, which expands into non_nullable_value_type nullable_type_annotation. Therefore, non_array_type may expand into non_nullable_value_type nullable_type_annotation. Substituting that:
non_array_type ( nullable_type_annotation rank_specifier+ )+
may be
non_nullable_value_type nullable_type_annotation ( nullable_type_annotation rank_specifier+ )+
Notice how nullable_type_annotation appears twice. The proposed grammar allows int??[] as a valid construction.
Nigel-Ecma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See TG2 email discussion for details.
jnm2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to wait for a meeting where @gafter is present to discuss this as well, but @jnm2 is keen to get his hands dirty with it when he finds time.
I made it happen! See #1386 for my proposed grammar changes. If we take my PR as the direction, @gafter's other changes in this PR will be valuable to move over.
BillWagner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once grammar validation is added, I'm ready to accept this.
| array_type | ||
| : non_array_type rank_specifier+ | ||
| | non_array_type rank_specifier+ | ||
| | non_array_type ( nullable_type_annotation rank_specifier+ )+ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd agree with @gafter. nullable_value_type is defined as non_nullable_value_type nullable_type_annotation. There's no additional condition for a nullable_value_type. So, int?? isn't a valid type.
Proposed replacement for #1287
@Nigel-Ecma Can you please help me set up the testing for this PR?