From: mame@...
Date: 2018-03-16T01:22:15+00:00
Subject: [ruby-core:86151] [Ruby trunk Feature#14606] Change begin-else-end without rescue from warning to syntax error

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


I'm not against the removeal.

BTW, surprisingly, the following code works "as intended."

```
def fib(x)
  if x >= 2
    a = fib(x - 1)
    b = fib(x - 2)
    return a + b
  end else x
end

p fib(10) #=> 55
```

----------------------------------------
Feature #14606: Change begin-else-end without rescue from warning to syntax error
https://bugs.ruby-lang.org/issues/14606#change-71030

* Author: joker1007 (Tomohiro Hashidate)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
~~~ ruby
begin
  p :foo
else
  p :bar
end

# => :foo
# => :bar
~~~

~~~ ruby
[1,2,3].each do
  p :foo
else
  p :bar
end

# => :foo
# => :bar
~~~

begin-else-end without rescue is useless and dangerous. (especially, do-else-end is easy to mistake)
In actually, programmer never intend to write like these.
Ruby interpreter can guard this case by syntax error.



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