Project

General

Profile

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

jeremyevans0 (Jeremy Evans), 07/29/2019 07:03 PM

View differences:

ext/ripper/tools/preproc.rb
45 45
  while line = f.gets
46 46
    case line
47 47
    when /\A%%/
48
      out << '%%' << $/
48
      out << "%%\n"
49 49
      return
50 50
    when /\A%token/
51 51
      out << line.sub(/<\w+>/, '<val>')
......
79 79
  while line = f.gets
80 80
    case line
81 81
    when %r</\*% *ripper(?:\[(.*?)\])?: *(.*?) *%\*/>
82
      out << DSL.new($2, ($1 || "").split(",")).generate << $/
82
      out << DSL.new($2, ($1 || "").split(",")).generate << "\n"
83 83
    when %r</\*%%%\*/>
84
      out << '#if 0' << $/
84
      out << "#if 0\n"
85 85
    when %r</\*%>
86
      out << '#endif' << $/
86
      out << "#endif\n"
87 87
    when %r<%\*/>
88
      out << $/
88
      out << "\n"
89 89
    when /\A%%/
90
      out << '%%' << $/
90
      out << "%%\n"
91 91
      return
92 92
    else
93 93
      out << line
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_compile_warn(p->ruby_sourcefile, p->ruby_sourceline,
8357
                "global variable $%c is deprecated", c);
8358
        }
8359
	/* fall through */
8350 8360
      case '~':		/* $~: match-data */
8351 8361
      case '*':		/* $*: argv */
8352 8362
      case '$':		/* $$: pid */
8353 8363
      case '?':		/* $?: last status */
8354 8364
      case '!':		/* $!: error string */
8355 8365
      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 8366
      case '=':		/* $=: ignorecase */
8362 8367
      case ':':		/* $:: load path */
8363 8368
      case '<':		/* $<: reading filename */
template/encdb.h.tmpl
58 58
          else
59 59
            name = $1
60 60
          end
61
          check_duplication(defs, $1, fn, $.)
61
          check_duplication(defs, $1, fn, f.line_no)
62 62
          next if BUILTIN_ENCODINGS[name]
63 63
          encodings << $1
64 64
          count += 1
......
71 71
          when /^ENC_REPLICATE\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
72 72
            raise ArgumentError,
73 73
            '%s:%d: ENC_REPLICATE: %s is not defined yet. (replica %s)' %
74
              [fn, $., $2, $1] unless defs[$2.upcase]
74
              [fn, f.lineno, $2, $1] unless defs[$2.upcase]
75 75
            count += 1
76 76
          when /^ENC_ALIAS\(\s*"([^"]+)"\s*,\s*"([^"]+)"/
77 77
            raise ArgumentError,
78 78
            '%s:%d: ENC_ALIAS: %s is not defined yet. (alias %s)' %
79
              [fn, $., $2, $1] unless defs[$2.upcase]
79
              [fn, f.lineno, $2, $1] unless defs[$2.upcase]
80 80
          when /^ENC_DUMMY\w*\(\s*"([^"]+)"/
81 81
            count += 1
82 82
          else
83 83
            next
84 84
          end
85
          check_duplication(defs, $1, fn, $.)
85
          check_duplication(defs, $1, fn, f.lineno)
86 86
          lines << line.sub(/;.*/m, "").chomp + ";" if line
87 87
        end
88 88
      end
template/transdb.h.tmpl
44 44
          from_to = "%s to %s" % [$1, $2]
45 45
          if converters[from_to]
46 46
            raise ArgumentError, '%s:%d: transcode "%s" is already registered at %s:%d' %
47
            [path, $., from_to, *converters[from_to].values_at(3, 4)]
47
            [path, f.lineno, from_to, *converters[from_to].values_at(3, 4)]
48 48
          else
49
            converters[from_to] = [$1, $2, fn[0..-3], path, $.]
49
            converters[from_to] = [$1, $2, fn[0..-3], path, f.lineno]
50 50
            converter_list << from_to
51 51
          end
52 52
        end
test/ruby/test_syntax.rb
605 605
    end
606 606
  end
607 607

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

  
615
    assert_no_warning(/global variable \$; is deprecated/) { eval('$;', binding, '-e') }
616
    assert_no_warning(/global variable \$, is deprecated/) { eval('$,', binding, '-e') }
617
    assert_no_warning(/global variable \$\/ is deprecated/) { eval('$/', binding, '-e') }
618
    assert_no_warning(/global variable \$\\ is deprecated/) { eval('$\\', binding, '-e') }
619
    assert_no_warning(/global variable \$\. is deprecated/) { eval('$.', binding, '-e') }
620
  end
621

  
608 622
  Bug7559 = '[ruby-dev:46737]'
609 623

  
610 624
  def test_lineno_command_call_quote