Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for assigning strings inside loop
Fixes #371 So this one was interesting. It's all to do with how strings get assigned: in the sample with the loop, the literal string "hello" only appears once in the source code (because it gets reused on each loop), so the parser only allocates a single value for that string. Which is fine. BUT... assigning `hi` didn't actually create a new instance of the string, it just pointed the variable `hi` at that value, and the `rock` operator used this way actually modifies its argument instead of returning a copy. So `rock hi with "!"` is actually modifying the value that was allocated by the parser - and so on the next loop, `hi` already has the exclamation point from the previous loop. Fixed by modifying the way the `Assign` statement works so that if you assign a string, it actually creates a copy of the string and assigns the variable to the copy, so the value allocated by the parser never gets modified.
- Loading branch information