Issue #14062 has been updated by Eregon (Benoit Daloze).


Currently the argument is ignored.
And I think it would make little sense in a file loaded by #require to affect the global exist status if it does a "return 1".
"exit 1" can be used for that, top-level return is to avoid loading anything further in the file when it's not needed in my understanding.

----------------------------------------
Bug #14062: Top-level return allows an argument
https://bugs.ruby-lang.org/issues/14062#change-67619

* Author: Eregon (Benoit Daloze)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.5.0dev (2017-10-26 trunk 60450) [x86_64-linux]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
~~~ ruby
puts "Here"
return 42 # or :foo, or any value
~~~

~~~
ruby test.rb
Here
~~~

Should it be a SyntaxError, as mentioned in https://bugs.ruby-lang.org/issues/4840#note-24 ?
It seems confusing to accept it silently, as one could expect the exact code to be affected by it (that should not be the case imho).

Discovered in https://github.com/ruby/spec/pull/530



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