Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3959c1d15ae8
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 176050c700fb
Choose a head ref
  • 2 commits
  • 2 files changed
  • 2 contributors

Commits on May 9, 2016

  1. Fixed a bug where sometimes NameError#receiver didn't return receiver

    When a NameError is raised from Struct#[], the #receiver should return the receiver object rather than raising "ArgumentError: no receiver is available".
    yuki24 committed May 9, 2016
    Copy the full SHA
    db233fc View commit details
  2. Merge pull request #3864 from yuki24/fix-nameerror-receiver-coming-fr…

    …om-struct
    
    Fixed a bug where NameError#receiver didn't return receiver when it's caused by Struct#[]
    headius committed May 9, 2016
    Copy the full SHA
    176050c View commit details
Showing with 11 additions and 1 deletion.
  1. +1 −1 core/src/main/java/org/jruby/RubyStruct.java
  2. +10 −0 test/jruby/test_name_error.rb
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/RubyStruct.java
Original file line number Diff line number Diff line change
@@ -466,7 +466,7 @@ public IRubyObject set(IRubyObject value, int index) {
}

private RaiseException notStructMemberError(String name) {
return getRuntime().newNameError("no member '" + name + "' in struct", name);
return getRuntime().newNameError("no member '" + name + "' in struct", this, name);
}

public final IRubyObject get(int index) {
10 changes: 10 additions & 0 deletions test/jruby/test_name_error.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'test/unit'

class TestNameError < Test::Unit::TestCase
def test_receiver_on_name_error_coming_from_struct
obj = Struct.new(:does_exist).new(nil)
name_error = assert_raise(NameError) { obj[:doesnt_exist] }

assert_equal obj, name_error.receiver
end
end