-
Notifications
You must be signed in to change notification settings - Fork 32
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
Compound assignment operators shouldn't use template
s
#94
Comments
As a further point, |
I tried to implement this, but changing |
Could you tell us which test is broken by this change ? |
The first "off by one in division" test case in |
update: nim-lang/Nim#19464 is fixed |
@konsumlamm Isn't this issue now just a matter of changing template to proc with a :%s/template ′(\c)=′/proc ′$1=′/g (Vim approximative sed regexp to change all template of compound assigments into procs). |
That fixes the issue for 1.6, but not for 1.4. So there are several possibilities for how to proceed:
|
Currently, e.g.
+=
is defined asThis causes
a
to be evaluated twice, which can produce unexpected results, when it's an expression that can cause side effects. For exampleprints
hello 42
twice, instead of just once.The solution would be to just make it a
func
instead. The same applies to-=
and*=
.The text was updated successfully, but these errors were encountered: