Skip to content

Commit 3ef1b38

Browse files
aardvark179chrisseaton
authored andcommitted
Changes based on review.
1 parent c3dfa6e commit 3ef1b38

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/main/java/org/truffleruby/core/numeric/IntegerNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ public Object compare(long a, Object b,
872872
@Specialization(guards = "!isRubyNumber(b)")
873873
public Object compare(DynamicObject a, Object b,
874874
@Cached("createPrivate()") CallDispatchHeadNode redoCompare) {
875-
return redoCompare.call(a, "redo_compare", coreStrings().SPACESHIP.getSymbol(), b);
875+
return redoCompare.call(a, "redo_compare_no_error", b);
876876
}
877877

878878
}

src/main/ruby/truffleruby/core/integer.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ def round(ndigits=undefined, half: nil)
186186
if kind_of? Integer and f.kind_of? Integer
187187
x = self < 0 ? -self : self
188188
x = if (half == :down)
189-
(x) / f
190-
else
189+
x / f
190+
else # :up or nil
191191
(x + f / 2) / f
192192
end
193193
x = (x / 2) * 2 if half == :even

src/main/ruby/truffleruby/core/numeric.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,11 @@ def math_coerce(other, error=:coerce_error)
241241
values = other.coerce(self)
242242

243243
unless Truffle::Type.object_kind_of?(values, Array) && values.length == 2
244-
return nil
244+
if error == :no_error
245+
return nil
246+
else
247+
raise TypeError, 'coerce must return [x, y]'
248+
end
245249
end
246250

247251
[values[1], values[0]]

0 commit comments

Comments
 (0)