[#35027] [Ruby 1.9-Bug#4352][Open] [patch] Fix eval(s, b) backtrace; make eval(s, b) consistent with eval(s) — "James M. Lawrence" <redmine@...>

Bug #4352: [patch] Fix eval(s, b) backtrace; make eval(s, b) consistent with eval(s)

16 messages 2011/02/01

[#35114] [Ruby 1.9-Bug#4373][Open] http.rb:677: [BUG] Segmentation fault — Christian Fazzini <redmine@...>

Bug #4373: http.rb:677: [BUG] Segmentation fault

59 messages 2011/02/06

[#35171] [Ruby 1.9-Bug#4386][Open] encoding: directive does not affect regex expressions — mathew murphy <redmine@...>

Bug #4386: encoding: directive does not affect regex expressions

9 messages 2011/02/09

[#35237] [Ruby 1.9-Bug#4400][Open] nested at_exit hooks run in strange order — Suraj Kurapati <redmine@...>

Bug #4400: nested at_exit hooks run in strange order

12 messages 2011/02/15

[ruby-core:35373] Re: [Ruby 1.9 - Bug #4440] [Open] odd evaluation order in a multiple assignment

From: Yusuke ENDOH <mame@...>
Date: 2011-02-24 14:37:56 UTC
List: ruby-core #35373
Sorry, I've sent a Japanese mail to ruby-core by mistake.
Translation :-)

Hi,

I have believed that Ruby evaluates everything from left to
right, but was betrayed by a multiple assignment:

  def foo
    p :foo
    []
  end
  def bar
    p :bar
  end

  x, foo[0] = bar, 0

Because "foo" precedes "bar", I expect that this prints :foo
and :bar in this order, but actually :bar and :foo.


I think that this is a matter in practice.  For example,

  x, y = y, x

is used to swap the two, but

  obj, obj.foo = obj.foo, obj

does not so.  This kind of code is often written to rotate
a tree.  In fact I realized this behavior when I was writing
a splay tree, like this:

  t.left, t.left.right, t = t.left.right, t, t.left


I don't think that this should be fixed in 1.9 series, but
can we fix this in 2.0?


Some people (in Japanese IRC) said me that the behavior is
expected, but note that

  foo[0] = bar

does print :foo and :bar in the order.

-- 
Yusuke Endoh <mame@tsg.ne.jp>

In This Thread