Skip to content

Usage of #[]= assignment in method argument broken #4323

@gettalong

Description

@gettalong

Environment

  • jruby 9.1.6.0-SNAPSHOT (2.3.1) 2016-11-08 cb5a7be Java HotSpot(TM) 64-Bit Server VM 25.91-b14 on 1.8.0_91-b14 +jit [linux-x86_64]
  • Linux noweto 4.4.0-25-generic LocalContextScope documentation improvement #44-Ubuntu SMP Fri Jun 10 18:19:48 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Expected Behavior

The following worked at least until JRuby 9.0.0.0 and works in MRI:

def modify(x)
  x << 'a'
end

modify(u = '')     # => "a"
u                  # => "a"
x = {}             # => {}
modify(x[5] = '')  # => "a"
x                  # => {5=>"a"}

Actual Behavior

At least from JRuby 9.1.5.0 onwards including the above listed JRuby 9.1.6.0 snapshot the following happens:

def modify(x)
  x << 'a'
end

modify(u = '')     # => "a"
u                  # => "a"
x = {}             # => {}
modify(x[5] = '')  # => "a"
x                  # => {5=>""}

The difference is in the last line where the string assigned to x[5] isn't modified anymore, leading to erroneous behaviour.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions