Number>>to:do: inlining is not transparent when loop index escapes

Project:GNU Smalltalk
Component:Base classes
Category:bug
Priority:normal
Assigned:bonzinip
Status:postponed
Description

The following code doesn't work as expected:

| c |
c := OrderedCollection new.
1 to: 10 do: [:each | c add: [each]].
c collect: [:each | each value]

-> OrderedCollection (11 11 11 11 11 11 11 11 11 11 11)

It works fine using (1 to: 10) do: [...]

Updates

#1 submitted by Paolo Bonzini on Sun, 01/24/2010 - 14:20
Title:Inlined blocks (Number>>to:do:)» Number>>to:do: inlining is not transparent when loop index escapes
Assigned to:Unassigned» bonzinip
Status:active» postponed

In order to fix this, copying blocks should be implemented.

User login