Update parser so that void type is rejected depending on the context#2590
Update parser so that void type is rejected depending on the context#2590
void type is rejected depending on the context#2590Conversation
|
We're getting more places where we specify what's allowed: |
|
@Morriar I'd like to keep parser_context old_context = parser.context;
parser.context.allow_void = true;
parse_type(parser);
parser.context = old_context;I’m planning to introduce two more flags for parsing |
6c54a47 to
9f8a133
Compare
Oops — they are constant while parsing a type, but they can change when parsing an entire signature. |
| rb_encoding *encoding; | ||
| rbs_parser_t *parser; | ||
| VALUE require_eof; | ||
| VALUE void_allowed; |
There was a problem hiding this comment.
The parse_type_arg is also used for parse_method_type and parse_signature.
Regarding the name allow_void, it is appropriate for type parsing, but for signature parsing, I think there is a possibility that it could be interpreted as allowing or disallowing all uses of void, regardless of the context in which it is used.
For example, looks disallowed to me.
RBS::Parser.parse_method_type("() -> void", allow_void: false)What do you think?
There was a problem hiding this comment.
It makes sense. I added two more arg types, parse_method_type_arg and parse_signature_arg, and use them for parse_method_type and parse_signature.
The two structs are identical currently, but a few attributes will be added to parse_method_type_arg to support options for self/instance/class type parsing.
7e79fc4 to
6130ccf
Compare
The `parse_type_list_with_commas` function was added after the first implementation of this PR.
This is a Follow-up to ruby#2590
This is a Follow-up to ruby#2590
This is a Follow-up to ruby#2590
This is a Follow-up to ruby#2590
This is a Follow-up to ruby#2590
This is a Follow-up to ruby#2590
No description provided.