Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Fix loop interpolation bug on Perl 5.28
Without this fix, the Strap demo [if-item-field] ... [/if-item-field] loop tags are broken on the flypage and elsewhere. This bug shows that Perl 5.28 no longer processes string concatenation from left to right such that it is safe to autoincrement a variable that is referred to elsewhere in the concatenation as well. I have not seen any other reports of people running into this problem, but the new behavior can be inferred from the "perl5280delta" documentation which notes under "Performance Enhancements": Many string concatenation expressions are now considerably faster, due to the introduction internally of a "multiconcat" opcode which combines multiple concatenations, and optionally a "=" or ".=", into a single action. The perlop documentation for "Auto-increment and Auto-decrement" reads: "++" and "--" work as in C. [...] Note that just as in C, Perl doesn't define when the variable is incremented or decremented. You just know it will be done sometime before or after the value is returned. This also means that modifying a variable twice in the same statement will lead to undefined behavior. Avoid statements like: $i = $i ++; print ++ $i + $i ++; Perl will not guarantee what the result of the above statements is. That does not address changing the variable once and referring to it in other places, but now it should.
- Loading branch information