Issue #14240 has been updated by nobu (Nobuyoshi Nakada).


jeremyevans0 (Jeremy Evans) wrote:
> > And non-default `$;` and `$,` are warned now.
> > Do you think these **names** should be warned too?
> 
> I don't feel strongly about it.  The `$;` and `$,` are currently run-time warnings based on the specific values passed when setting the values.  akr's previous comment indicated that the warnings of the five variables should be at compile time.

There are tons of that warnings, and it is not easy to suppress parser warning within the given file only.

> One problem with the implementation in my previous patch is that it warns at the wrong location. Switching from `rb_warn` to `rb_compile_warn` fixes that issue.

It should be `rb_warn1` and `WARN_I(c)` for ripper.
And a typo `f.line_no` in template/encdb.h.tmpl.


----------------------------------------
Bug #14240: warn four special variables: $; $, $/ $\
https://bugs.ruby-lang.org/issues/14240#change-80221

* Author: akr (Akira Tanaka)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
I think the four special variables for separators should be deprecated.

```
$/    input record separator (default argument for "gets")
$\    output record separator ("print" prints it at last)
$,    default separator for Array#join and print
$;    default separator for String#split
```

I feel many program doesn't work if they are set to non-default value.

Since they are global, not thread local,
we can not change these variables safely in a multi threaded program.

So, I think we should warn them (and delete them in future).





---Files--------------------------------
warn-5-gvars.patch (2.31 KB)
warn-5-gvars-v2.patch (5.44 KB)


-- 
https://bugs.ruby-lang.org/