-
Notifications
You must be signed in to change notification settings - Fork 56
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
Fix wrong parsing when a function call with a (one or more) variable … #327
base: master
Are you sure you want to change the base?
Conversation
…is inside a using statement. Instead of being parsed as invocation_expression it is being parsed as variable_declaration because of tuple_pattern.
Might be an acceptable fix for: |
So while it solves one individual issue this breaks things by renaming Best option here might be to see if you can keep the new using patterns but alias them so they don't have the using prefix (there are some examples in the grammar). |
using_variable_declaration: $ => seq( | ||
field('type', $._type), | ||
commaSep1($.using_variable_declarator) | ||
), |
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 think using_variable_declaration
could be reused in fixed_statement
too, so I'd rename it to variable_declaration_no_tuple
, or something similar.
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 really prefer we keep the names aligned with Roslyn. Apart from the compatibility it really helps understanding how the grammar rules change given the ongoing evolution of C#.
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.
So what name should I use?
|
||
using_variable_declarator: $ => seq( | ||
field('name', $.identifier), | ||
optional($.bracketed_argument_list), |
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.
Do we need optional($.bracketed_argument_list)
? Why was it added to variable_declarator
in the first place?
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 have no idea, unfortunately.
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.
@damieng Can you think of a case when we'd need the bracketed_argument_list
in variable_declarator
? I reran the tests without it, and everything passes.
using_variable_declarator: $ => seq( | ||
field('name', $.identifier), | ||
optional($.bracketed_argument_list), | ||
optional($.equals_value_clause) |
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.
Is it really optional to have an equals_value_clause
in a using
statement?
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.
Again, I don't know.
using_statement: $ => seq( | ||
optional('await'), | ||
'using', | ||
'(', | ||
choice($.variable_declaration, $._expression), | ||
choice($.using_variable_declaration, $._expression), |
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.
choice($.using_variable_declaration, $._expression), | |
choice(alias($.using_variable_declaration, $.variable_declaration), $._expression), |
@@ -226,6 +226,7 @@ | |||
|
|||
;; Variable declarations | |||
(variable_declarator (identifier) @variable) | |||
(using_variable_declarator (identifier) @variable) |
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 think we wouldn't need this if the alias was added.
@damieng @tamasvajk First of all, thanks for taking a look. Much appreciated. |
…is inside a using statement. Instead of being parsed as invocation_expression it is being parsed as variable_declaration because of tuple_pattern.