Issue #15747 has been reported by wanabe (_ wanabe).

----------------------------------------
Bug #15747: `(..1).last(2)` should return array but raise TypeError
https://bugs.ruby-lang.org/issues/15747

* Author: wanabe (_ wanabe)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.7.0dev (2019-04-04 trunk 67430) [x86_64-linux]
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
`Range#last` with argument for beginless range shouldn't raise exception, should it?

```
$ ./miniruby -ve 'p (..1).last(2)'
ruby 2.7.0dev (2019-04-04 trunk 67430) [x86_64-linux]
Traceback (most recent call last):
	4: from -e:1:in `<main>'
	3: from -e:1:in `last'
	2: from -e:1:in `to_a'
	1: from -e:1:in `to_a'
-e:1:in `each': can't iterate from NilClass (TypeError)
```

`Range#last` without argument works fine.

```
$ ./miniruby -ve 'p (..1).last'
ruby 2.7.0dev (2019-04-04 trunk 67430) [x86_64-linux]
1
```



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>