-
Notifications
You must be signed in to change notification settings - Fork 224
Update parser so that void
type is rejected depending on the context
#2590
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
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. |
@@ -85,6 +85,7 @@ struct parse_type_arg { | |||
rb_encoding *encoding; | |||
rbs_parser_t *parser; | |||
VALUE require_eof; | |||
VALUE void_allowed; |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.