Currently, the grammar defines three rules related to assignment:
variable_declaration: used in const expressions and let bindings
named_field: used in named tuples and named arguments
assignment_expression: used everywhere else
variable_declaration doesn't actually do anything right now. const and let rules could be defined in terms of assignment_expression. The only place variable_declaration might be useful is in global/local declarations, but those are not defined in the grammar yet.
assignment_expression is not defined as an _expression to avoid conflicts. This is only a problem with simple assignments, but compound assignments don't have that problem. In fact, it's necessary to allow compound assignments in more places to allow things like xs[i+=1].
A viable solution might be:
Define a rule assignment_statement (that only uses =)
Redefine const, let, etc. to use assignment_statement
Redefine assignment_expression to only use compound assignments
Currently, the grammar defines three rules related to assignment:
variable_declaration
: used in const expressions and let bindingsnamed_field
: used in named tuples and named argumentsassignment_expression
: used everywhere elsevariable_declaration
doesn't actually do anything right now.const
andlet
rules could be defined in terms ofassignment_expression
. The only placevariable_declaration
might be useful is in global/local declarations, but those are not defined in the grammar yet.assignment_expression
is not defined as an_expression
to avoid conflicts. This is only a problem with simple assignments, but compound assignments don't have that problem. In fact, it's necessary to allow compound assignments in more places to allow things likexs[i+=1]
.A viable solution might be:
assignment_statement
(that only uses=
)const
,let
, etc. to useassignment_statement
assignment_expression
to only use compound assignmentsFixing quote expressions is necessary to add local/global scope qualifiers to avoid test regressions. see https://github.com/tree-sitter/tree-sitter-julia/pull/6#issuecomment-663881117 (that's why this is an issue and not a PR).