Skip to content
This repository
Browse code

Merge branch 'master' of github.com:MagLev/maglev into tim/fix-253

  • Loading branch information...
commit bfc61a202265aff6023e6df4c2f8366c8f2306b2 2 parents ae2ad9f + dd8cd1c
Tim Felgentreff authored February 02, 2013
12  src/kernel/bootstrap/Array.rb
@@ -1553,7 +1553,7 @@ def rindex(element)
1553 1553
 
1554 1554
   def shift(count=MaglevUndefined)  # added in 1.8.7
1555 1555
     if count._equal?(MaglevUndefined) 
1556  
-      return self.shift()
  1556
+      return self.__shift
1557 1557
     end
1558 1558
     cnt = Maglev::Type.coerce_to(count, Fixnum, :to_int)
1559 1559
     if cnt < 0
@@ -1574,16 +1574,10 @@ def shift(count=MaglevUndefined)  # added in 1.8.7
1574 1574
   end
1575 1575
 
1576 1576
   def shift
1577  
-    sz = self.__size
1578  
-    elem = nil
1579  
-    unless sz._equal?(0)
1580  
-      elem = self.__at(0)
1581  
-      self.__remove_from_to_(1, 1)  # one-based args
1582  
-    end
1583  
-    elem
  1577
+    self.__shift
1584 1578
   end
1585 1579
 
1586  
-  def __shift  # used by Argf implementation
  1580
+  def __shift
1587 1581
     sz = self.__size
1588 1582
     elem = nil
1589 1583
     unless sz._equal?(0)
11  src/test/github250.rb
... ...
@@ -0,0 +1,11 @@
  1
+class Sexp < Array
  2
+  def shift
  3
+    raise if self.empty?
  4
+    super
  5
+  end
  6
+end
  7
+
  8
+s = Sexp.new
  9
+s << 42
  10
+raises "Shift broken" unless s.shift == 42
  11
+# Passes if it doesn't cause infinite recursion
1  src/test/vmunit.conf
@@ -450,6 +450,7 @@ github211.rb
450 450
 github222.rb
451 451
 github224.rb
452 452
 github243.rb
  453
+github250.rb
453 454
 
454 455
 testMarshal.rb   # after other coverage of Hash
455 456
 #

0 notes on commit bfc61a2

Please sign in to comment.
Something went wrong with that request. Please try again.