Project

General

Profile

Bug #14240 ยป warn-5-gvars.patch

jeremyevans0 (Jeremy Evans), 07/26/2019 11:15 PM

View differences:

parse.y
8347 8347
	pushback(p, c);
8348 8348
	c = '_';
8349 8349
	/* fall through */
8350
      case '/':         /* $/: input record separator */
8351
      case '\\':        /* $\: output record separator */
8352
      case ';':         /* $;: field separator */
8353
      case ',':         /* $,: output field separator */
8354
      case '.':         /* $.: last read line number */
8355
        if (c != '_' && strcmp(p->ruby_sourcefile, "-e")) {
8356
            rb_warn("global variable $%c is deprecated", c);
8357
        }
8358
	/* fall through */
8350 8359
      case '~':		/* $~: match-data */
8351 8360
      case '*':		/* $*: argv */
8352 8361
      case '$':		/* $$: pid */
8353 8362
      case '?':		/* $?: last status */
8354 8363
      case '!':		/* $!: error string */
8355 8364
      case '@':		/* $@: error position */
8356
      case '/':		/* $/: input record separator */
8357
      case '\\':		/* $\: output record separator */
8358
      case ';':		/* $;: field separator */
8359
      case ',':		/* $,: output field separator */
8360
      case '.':		/* $.: last read line number */
8361 8365
      case '=':		/* $=: ignorecase */
8362 8366
      case ':':		/* $:: load path */
8363 8367
      case '<':		/* $<: reading filename */
test/ruby/test_syntax.rb
605 605
    end
606 606
  end
607 607

  
608
  def test_deprecated_global_variable
609
    assert_warning(/global variable \$; is deprecated/) { eval('$;') }
610
    assert_warning(/global variable \$, is deprecated/) { eval('$,') }
611
    assert_warning(/global variable \$\/ is deprecated/) { eval('$/') }
612
    assert_warning(/global variable \$\\ is deprecated/) { eval('$\\') }
613
    assert_warning(/global variable \$\. is deprecated/) { eval('$.') }
614
  end
615

  
608 616
  Bug7559 = '[ruby-dev:46737]'
609 617

  
610 618
  def test_lineno_command_call_quote
611
-