Implement compound assignments (e.g. {% mut a += 1 %})#685
Implement compound assignments (e.g. {% mut a += 1 %})#685GuillaumeGomez merged 2 commits intoaskama-rs:mainfrom
{% mut a += 1 %})#685Conversation
1986b21 to
6be1999
Compare
|
Huuuuuuum. I don't like the fact that we overload the |
|
|
|
Agreed! |
6be1999 to
4b0ee18
Compare
{% let a += 1 %}){% mut a += 1 %})
|
Note for me of tomorrow for review: check how operators are checked, if an operator is needed, check it's only one of the following: |
|
|
|
I was sure the |
|
|
||
| fn filter<'a: 'l, 'l>(i: &mut InputStream<'a, 'l>) -> ParseResult<'a, Filter<'a>> { | ||
| preceded(('|', not('|')), cut_err(Filter::parse)).parse_next(i) | ||
| preceded(('|', not(one_of(['|', '=']))), cut_err(Filter::parse)).parse_next(i) |
| ```jinja | ||
| {% let mut counter = 0 %} | ||
| {% for i in 1..=10 %} | ||
| {% mut counter += 1 %} |
There was a problem hiding this comment.
To ensure the output is as described.
| {% mut counter += 1 %} | |
| {%- mut counter += 1 -%} |
There was a problem hiding this comment.
That was not the quite problem with the code (I ignored spaces). I wrote += 1, but I meant += i. :) Fixed.
|
|
||
| fn filter<'a: 'l, 'l>(i: &mut InputStream<'a, 'l>) -> ParseResult<'a, Filter<'a>> { | ||
| preceded(('|', not('|')), cut_err(Filter::parse)).parse_next(i) | ||
| preceded(('|', not(one_of(['|', '=']))), cut_err(Filter::parse)).parse_next(i) |
There was a problem hiding this comment.
Can you add a ui test for this one please?
| Ok("&") | ||
| } else { | ||
| let good = keyword("bitand").value(None); | ||
| let bad = ('&', not(one_of(['&', '=']))).span().map(Some); |
There was a problem hiding this comment.
Please add a ui test for this one.
There was a problem hiding this comment.
Already tested by testing/tests/ui/iso646.rs.
|
Looks good to me, thanks! Please add the ui tests I mentioned, then it should be ready for merge. Well done! |
a7827b0 to
47366c1
Compare
47366c1 to
579f928
Compare
|
Thanks! |
| // is valid rust code, because the value of any assignment (compound or not) is `()`. | ||
| // This way the generator does not need to know about compound assignments for them | ||
| // to work. | ||
| Ok(Box::new(Node::Let(WithSpan::new( |
There was a problem hiding this comment.
Late thought about this: why not creating a new type for it? Would allow to generate a cleaner AST too.
There was a problem hiding this comment.
Actually, laziness on my side. Nothing more, nothing less. :)
I think it can be quite useful to modify variables that are declared inside a template.
Is it possible to "resolve" a discussion? Let's find out!Resolves #662.The answer is: no.