Issue #15732 has been reported by localhostdotdev (localhost .dev).

----------------------------------------
Bug #15732: Strict mode
https://bugs.ruby-lang.org/issues/15732

* Author: localhostdotdev (localhost .dev)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.4: UNKNOWN, 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
A lot of issues could be easily prevented with a strict mode, for instance:

- Passing a block to a method that doesn't accept blocks could raise an exception, e.g. methods would be required to explicitly ask for a block (def a(..., &block))
- $1, $2, etc. variables when matching with a regex would not be created
- Could throw error when re-assigning constant

And maybe more controversial:

- Using reversed keywords as argument names
- Using method name as argument name
- Using ambitious class/constant/method names (e.g. `class A; end; class B; class A; def me; A; end; end`

I'm sure there is more, using things rubocop does for instance: https://github.com/rubocop-hq/rubocop/blob/master/manual/cops.md

I could be implemented as a magic header, e.g. `# strict_mode: true`.

This is obviously a similar idea from Javascript's strict mode: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode



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