pharo
pharo copied to clipboard
#to:do: optimization evaluates argument before receiver
Bug description
The first argument of the to:do: message send is evaluated before the receiver.
To Reproduce Evaluate:
| stream results |
results := OrderedCollection new.
stream := #( 1 5 ) readStream.
stream next to: stream next do: [ :i | results add: i ].
results
This should return an ordered collection with numbers 1 to 5, but instead returns an empty collection as the to: argument is evaluated before the receiver.
Expected behavior The receiver of the message should be evaluated before an arguments like happens with non-optimized messages.
Version information:
- Pharo Version: Pharo 13 (and 10 and likely most other versions).
Thanks, I will check