Skip to content

Commit b6b6b61

Browse files
committed
Handle ImmutableRubyObject in Float#<=> sepcialisations
1 parent def844f commit b6b6b61

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

spec/ruby/core/float/comparison_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
(1.0 <=> "1").should be_nil
1717
(1.0 <=> "1".freeze).should be_nil
1818
(1.0 <=> :one).should be_nil
19+
(1.0 <=> true).should be_nil
1920
end
2021

2122
it "compares using #coerce when argument is not a Float" do

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

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
import org.truffleruby.core.string.RubyString;
3333
import org.truffleruby.core.string.StringNodes;
3434
import org.truffleruby.core.string.StringUtils;
35-
import org.truffleruby.language.Nil;
3635
import org.truffleruby.language.RubyDynamicObject;
3736
import org.truffleruby.language.Visibility;
3837
import org.truffleruby.language.control.RaiseException;
@@ -414,14 +413,8 @@ protected int compare(double a, double b) {
414413
return Double.compare(a, b);
415414
}
416415

417-
@Specialization(guards = { "!isNaN(a)", "!isRubyBignum(b)" })
418-
protected Object compare(double a, RubyDynamicObject b,
419-
@Cached DispatchNode redoCompare) {
420-
return redoCompare.call(a, "redo_compare_bad_coerce_return_error", b);
421-
}
422-
423-
@Specialization(guards = { "!isNaN(a)" })
424-
protected Object compare(double a, Nil b,
416+
@Specialization(guards = { "!isNaN(a)", "!isRubyNumber(b)" })
417+
protected Object compare(double a, Object b,
425418
@Cached DispatchNode redoCompare) {
426419
return redoCompare.call(a, "redo_compare_bad_coerce_return_error", b);
427420
}

0 commit comments

Comments
 (0)