From: eregontp@...
Date: 2019-07-27T11:10:01+00:00
Subject: [ruby-core:93949] [Ruby master Bug#14062] Top-level return allows	an argument

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


jeremyevans0 (Jeremy Evans) wrote:
> Attached is a patch that adds a warning when using a top-level return with an argument.

Thank you, it looks good to me.
Although, I would suggest to change the warning message to one of these:
```
argument of top-level return is ignored
argument of return at top-level is ignored
```

Could you commit it?

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

* 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 exit code to be affected by it (that should not be the case imho).

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

---Files--------------------------------
top-level-return-warn-argument.patch (1.32 KB)


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