#342 √ resolved
Ryan Davis

method call argument and receiver eval order

Reported by Ryan Davis | February 22nd, 2008 @ 02:06 PM | in 1.0 preview

Comments and changes to this ticket

  • Ryan Davis

    Ryan Davis February 29th, 2008 @ 04:08 PM

    • → State changed from “new” to “open”
  • Ryan Davis

    Ryan Davis March 10th, 2008 @ 03:50 PM

    • → Assigned user changed from “Ryan Davis” to “Evan Phoenix”
    • → Title changed from “talk to wilson about masgn stuff for activesupport” to “method call argument eval order”

    (was: talk to wilson about masgn stuff for activesupport)

  • Juha Pohjalainen

    Juha Pohjalainen July 15th, 2008 @ 02:10 PM

    • → Tag changed from “” to “compatibility compiler spec”
    • → Title changed from “method call argument eval order” to “method call argument and receiver eval order”

    Both receiver and arguments are evaluated from right to left (and not left to right as MRI or JRuby does).

    I've (tried to) attached a spec which runs in MRI and JRuby, and not in Rubinius.

    I think code that causes this is located at Compiler::Call#bytecode (in file lib/compiler/bytecode.rb).

    Bytecode there is generated at following order:

    • emit_args (in reverse order, which causes arguments to be evaluated in reverse order)
    • @block.bytecode
    • receiver_bytecode evaluated last

    That generates "correct" bytecode and unfortunately that does not work correctly. It is totally different thing to generate working code with correct evaluation order.

    I also suspect that there are (bytecode) specs which are wrong, since they are assuming that generated bytecode is correct, but it evaluates things in wrong order.

    I think this is major one, since it affect what parameters applications receive. So is anybody working on this? Or have ideas how to fix it?

  • Evan Phoenix

    Evan Phoenix July 15th, 2008 @ 02:14 PM

    This can not be fixed with the shotgun, the current VM, as it requires the right to left ordering.

    This is fix in the C++ VM though. Once it's merged in, this can be closed.

  • Brian Ford

    Brian Ford December 2nd, 2008 @ 02:43 PM

    • → State changed from “open” to “resolved”

    Merged. Closed. Yay.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Attachments