Issue #14824 has been updated by mame (Yusuke Endoh).


First of all, I have no strong opinion about this issue.  The current behavior of irb looks weird to me, but it may be okay because irb users can work around the issue easily.

In principle, I expect irb to cut the shortest lines that parses.  For example, consider the following input:

```
foo
.bar
```

Irb first evaluates only the first line `foo`, and the second line `.bar` causes SyntaxError.  This is the behavior that I expect.  In the same logic, I expect `1..` to be cut because it parses.

```
irb(main):001:0> 1..
```

BTW, a line `obj.+` causes line continuation.  This is a behavior that I don't expect:

```
irb(main):001:0> obj = Object.new
=> #<Object:0x0000560275fa4b00>
irb(main):002:0> def obj.+(); 42; end
=> :+
irb(main):003:0> obj.+
irb(main):004:0* 
irb(main):005:0* ;
=> 42
```

If the method name is different than `+`, say `foo`, irb does not wait for the next line.  Looks very inconsistent.

```
irb(main):006:0> def obj.foo(); 42;end
=> :foo
irb(main):007:0> obj.foo
=> 42
```

So, I cannot see any consistent policy about line continuation.

But again, it's okay to me in the case of irb.  Few users will encounter such a corner case.  Even if someone does, s/he can avoid such a behavior by explicit semicolon or parens or something else.

----------------------------------------
Bug #14824: Endless Range Support in irb
https://bugs.ruby-lang.org/issues/14824#change-72399

* Author: jeremyevans0 (Jeremy Evans)
* Status: Rejected
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.6.0preview2 (2018-05-31 trunk 63539) [x86_64-openbsd]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
`irb` currently doesn't have great support for endless ranges, forcing you to use explicit parentheses around the endless range. Without explicit parentheses, it treats the endless range as a line continuation.

~~~
irb(main):001:0> 1..
irb(main):002:0* ;
=> 1..
irb(main):003:0> (1..)
=> 1..
irb(main):004:0>
~~~

Ranges with ends do not require parentheses in `irb`, and endless ranges should have the same behavior.



-- 
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>