Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Range#each should raise a TypeError if the first element is a Time object #699

Merged
merged 1 commit into from

2 participants

@atambo
Collaborator

No description provided.

@headius headius merged commit ec393a4 into jruby:master

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
1  spec/tags/1.9/ruby/core/range/each_tags.txt
@@ -1 +0,0 @@
-fails:Range#each raises a TypeError if the first element is a Time object
View
4 src/org/jruby/RubyRange.java
@@ -453,7 +453,9 @@ public IRubyObject each19(final ThreadContext context, final Block block) {
Ruby runtime = context.runtime;
if (!block.isGiven()) return enumeratorize(runtime, this, "each");
- if (begin instanceof RubyFixnum && end instanceof RubyFixnum) {
+ if (begin instanceof RubyTime) {
+ throw runtime.newTypeError("can't iterate from Time");
+ } else if (begin instanceof RubyFixnum && end instanceof RubyFixnum) {
fixnumEach(context, runtime, block);
} else if (begin instanceof RubyString) {
((RubyString) begin).uptoCommon19(context, end, isExclusive, block);
Something went wrong with that request. Please try again.