Skip to content

Commit

Permalink
Warn non-nil $, in IO#print too
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Feb 23, 2020
1 parent 0ed3384 commit 588a86e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions io.c
Expand Up @@ -7615,6 +7615,9 @@ rb_io_print(int argc, const VALUE *argv, VALUE out)
line = rb_lastline_get();
argv = &line;
}
if (argc > 1 && !NIL_P(rb_output_fs)) {
rb_warn("$, is set to non-nil value");
}
for (i=0; i<argc; i++) {
if (!NIL_P(rb_output_fs) && i>0) {
rb_io_write(out, rb_output_fs);
Expand Down
2 changes: 1 addition & 1 deletion test/ruby/test_io.rb
Expand Up @@ -2572,7 +2572,7 @@ def test_print_separators
$\ = "\n"
pipe(proc do |w|
w.print('a')
w.print('a','b','c')
EnvUtil.suppress_warning {w.print('a','b','c')}
w.close
end, proc do |r|
assert_equal("a\n", r.gets)
Expand Down

0 comments on commit 588a86e

Please sign in to comment.