Closed Maumagnaguagno closed 2 years ago
This is because the a.shift
is evaluated twice by TruffleRuby, but only once by CRuby.
We should fix that.
This variant has no issue:
a = [1,2,3]
h = {}
until a.empty?
p a
e = a.shift
h[e] ||= false
end
p h
Our translation of operator assignment nodes seems half correct. We correctly store the receiver as a local variable, but we do not do this correctly with any arguments passed to that receiver.
The fix for this has now been merged into master.
The following code has different behavior in TruffleRuby 22.1.0 and CRuby 3.1.2.
See outputs below:
To my surprise, replacing
||=
with=
makes both Rubies output the same. Forgive me if this is already fixed or if there is a related open issue, my search resulted in nothing similar.