Skip to content
This repository

fix some error message in Struct#[] #278

Merged
merged 1 commit into from over 1 year ago

3 participants

Kenichi Kamiya Don't Add Me To Your Organization a.k.a The Travis Bot Charles Oliver Nutter
Kenichi Kamiya

For below case.

Foo = Struct.new :foo
foo = Foo.new true

MRI/YARV

ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]

foo[-2]   #=> offset -1 too small for struct(size:1) (IndexError)
foo[:bar] #=> no member 'bar' in struct (NameError)

JRuby

jruby 1.7.0.preview2 (1.9.3p203) 2012-08-31 aeef1b8 on Java HotSpot(TM) 64-Bit Server VM 1.6.0_33-b03-424-11M3720 [darwin-x86_64]

foo[-2]   #=> IndexError: offset -1 too large for struct (size:1)
foo[:bar] #=> NameError: bar is not struct member
Don't Add Me To Your Organization a.k.a The Travis Bot

This pull request fails (merged 17fa907 into b247119).

Charles Oliver Nutter headius merged commit 5e1ea4a into from September 28, 2012
Charles Oliver Nutter headius closed this September 28, 2012
Kenichi Kamiya kachick deleted the branch December 19, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 01, 2012
Kenichi Kamiya fix error message in Struct#[] 17fa907
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 5 additions and 5 deletions. Show diff stats Hide diff stats

  1. 10  src/org/jruby/RubyStruct.java
10  src/org/jruby/RubyStruct.java
@@ -471,7 +471,7 @@ public IRubyObject set(IRubyObject value, int index) {
471 471
     }
472 472
 
473 473
     private RaiseException notStructMemberError(String name) {
474  
-        return getRuntime().newNameError(name + " is not struct member", name);
  474
+        return getRuntime().newNameError("no member '" + name + "' in struct", name);
475 475
     }
476 476
 
477 477
     public IRubyObject get(int index) {
@@ -624,9 +624,9 @@ public IRubyObject aref(IRubyObject key) {
624 624
         idx = idx < 0 ? values.length + idx : idx;
625 625
 
626 626
         if (idx < 0) {
627  
-            throw getRuntime().newIndexError("offset " + idx + " too large for struct (size:" + values.length + ")");
  627
+            throw getRuntime().newIndexError("offset " + idx + " too small for struct(size:" + values.length + ")");
628 628
         } else if (idx >= values.length) {
629  
-            throw getRuntime().newIndexError("offset " + idx + " too large for struct (size:" + values.length + ")");
  629
+            throw getRuntime().newIndexError("offset " + idx + " too large for struct(size:" + values.length + ")");
630 630
         }
631 631
 
632 632
         return values[idx];
@@ -643,9 +643,9 @@ public IRubyObject aset(IRubyObject key, IRubyObject value) {
643 643
         idx = idx < 0 ? values.length + idx : idx;
644 644
 
645 645
         if (idx < 0) {
646  
-            throw getRuntime().newIndexError("offset " + idx + " too large for struct (size:" + values.length + ")");
  646
+            throw getRuntime().newIndexError("offset " + idx + " too small for struct(size:" + values.length + ")");
647 647
         } else if (idx >= values.length) {
648  
-            throw getRuntime().newIndexError("offset " + idx + " too large for struct (size:" + values.length + ")");
  648
+            throw getRuntime().newIndexError("offset " + idx + " too large for struct(size:" + values.length + ")");
649 649
         }
650 650
 
651 651
         modify();
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.