brakeman 5.4.1 → 6.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +14 -0
  3. data/README.md +2 -2
  4. data/bundle/load.rb +3 -4
  5. data/bundle/ruby/3.1.0/gems/parallel-1.23.0/lib/parallel/version.rb +4 -0
  6. data/bundle/ruby/3.1.0/gems/{parallel-1.22.1 → parallel-1.23.0}/lib/parallel.rb +43 -3
  7. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/History.rdoc +38 -0
  8. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/Manifest.txt +2 -0
  9. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/README.rdoc +2 -1
  10. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/compare/normalize.rb +1 -0
  11. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby20_parser.rb +4267 -4284
  12. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby20_parser.y +50 -26
  13. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby21_parser.rb +4241 -4240
  14. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby21_parser.y +50 -26
  15. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby22_parser.rb +4289 -4290
  16. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby22_parser.y +50 -26
  17. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby23_parser.rb +4274 -4243
  18. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby23_parser.y +50 -26
  19. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby24_parser.rb +4279 -4298
  20. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby24_parser.y +50 -26
  21. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby25_parser.rb +4270 -4289
  22. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby25_parser.y +50 -26
  23. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby26_parser.rb +4270 -4289
  24. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby26_parser.y +50 -26
  25. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby27_parser.rb +4173 -4206
  26. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby27_parser.y +50 -26
  27. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby30_parser.rb +6029 -5971
  28. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby30_parser.y +135 -86
  29. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby31_parser.rb +6195 -6184
  30. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby31_parser.y +136 -87
  31. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby32_parser.rb +13601 -0
  32. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2/lib/ruby3_parser.yy → ruby_parser-3.20.3/lib/ruby32_parser.y} +158 -163
  33. data/bundle/ruby/3.1.0/gems/ruby_parser-3.20.3/lib/ruby3_parser.yy +3635 -0
  34. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby_lexer.rb +15 -7
  35. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby_lexer.rex.rb +1 -1
  36. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby_lexer_strings.rb +2 -2
  37. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby_parser.rb +2 -0
  38. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby_parser.yy +50 -26
  39. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby_parser_extras.rb +25 -19
  40. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/tools/munge.rb +8 -2
  41. data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/tools/ripper.rb +14 -12
  42. data/bundle/ruby/3.1.0/gems/{sexp_processor-4.16.1 → sexp_processor-4.17.0}/History.rdoc +13 -0
  43. data/bundle/ruby/3.1.0/gems/{sexp_processor-4.16.1 → sexp_processor-4.17.0}/lib/pt_testcase.rb +3 -3
  44. data/bundle/ruby/3.1.0/gems/{sexp_processor-4.16.1 → sexp_processor-4.17.0}/lib/sexp.rb +8 -2
  45. data/bundle/ruby/3.1.0/gems/{sexp_processor-4.16.1 → sexp_processor-4.17.0}/lib/sexp_processor.rb +1 -1
  46. data/bundle/ruby/3.1.0/gems/{sexp_processor-4.16.1 → sexp_processor-4.17.0}/lib/strict_sexp.rb +6 -5
  47. data/lib/brakeman/app_tree.rb +0 -1
  48. data/lib/brakeman/checks/check_content_tag.rb +8 -5
  49. data/lib/brakeman/checks/check_eol_ruby.rb +3 -1
  50. data/lib/brakeman/report/report_github.rb +1 -1
  51. data/lib/brakeman/scanner.rb +0 -1
  52. data/lib/brakeman/tracker/config.rb +15 -11
  53. data/lib/brakeman/version.rb +1 -1
  54. data/lib/brakeman.rb +6 -2
  55. metadata +56 -68
  56. data/bundle/ruby/3.1.0/gems/parallel-1.22.1/lib/parallel/processor_count.rb +0 -44
  57. data/bundle/ruby/3.1.0/gems/parallel-1.22.1/lib/parallel/version.rb +0 -4
  58. data/bundle/ruby/3.1.0/gems/ruby_parser-legacy-1.0.0/History.rdoc +0 -6
  59. data/bundle/ruby/3.1.0/gems/ruby_parser-legacy-1.0.0/Manifest.txt +0 -19
  60. data/bundle/ruby/3.1.0/gems/ruby_parser-legacy-1.0.0/README.rdoc +0 -54
  61. data/bundle/ruby/3.1.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby18_parser.rb +0 -5794
  62. data/bundle/ruby/3.1.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby18_parser.y +0 -1909
  63. data/bundle/ruby/3.1.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby19_parser.rb +0 -6186
  64. data/bundle/ruby/3.1.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby19_parser.y +0 -2117
  65. data/bundle/ruby/3.1.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rb +0 -1412
  66. data/bundle/ruby/3.1.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex +0 -179
  67. data/bundle/ruby/3.1.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_lexer.rex.rb +0 -323
  68. data/bundle/ruby/3.1.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_parser.rb +0 -30
  69. data/bundle/ruby/3.1.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy/ruby_parser_extras.rb +0 -1388
  70. data/bundle/ruby/3.1.0/gems/ruby_parser-legacy-1.0.0/lib/ruby_parser/legacy.rb +0 -5
  71. /data/bundle/ruby/3.1.0/gems/{parallel-1.22.1 → parallel-1.23.0}/MIT-LICENSE.txt +0 -0
  72. /data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/debugging.md +0 -0
  73. /data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/gauntlet.md +0 -0
  74. /data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/rp_extensions.rb +0 -0
  75. /data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/rp_stringscanner.rb +0 -0
  76. /data/bundle/ruby/3.1.0/gems/{ruby_parser-3.19.2 → ruby_parser-3.20.3}/lib/ruby_lexer.rex +0 -0
  77. /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.16.1 → sexp_processor-4.17.0}/Manifest.txt +0 -0
  78. /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.16.1 → sexp_processor-4.17.0}/README.rdoc +0 -0
  79. /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.16.1 → sexp_processor-4.17.0}/lib/composite_sexp_processor.rb +0 -0
  80. /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.16.1 → sexp_processor-4.17.0}/lib/sexp_matcher.rb +0 -0
  81. /data/bundle/ruby/3.1.0/gems/{sexp_processor-4.16.1 → sexp_processor-4.17.0}/lib/unique.rb +0 -0
@@ -96,9 +96,9 @@ rule
96
96
  result = iter
97
97
  }
98
98
 
99
- begin_block: tLCURLY { result = lexer.lineno } top_compstmt tRCURLY
99
+ begin_block: tLCURLY top_compstmt tRCURLY
100
100
  {
101
- _, line, stmt, _ = val
101
+ (_, line), stmt, _ = val
102
102
  result = new_iter s(:preexe).line(line), 0, stmt
103
103
  }
104
104
 
@@ -221,6 +221,7 @@ rule
221
221
  | lhs tEQL mrhs
222
222
  {
223
223
  lhs, _, rhs = val
224
+
224
225
  result = new_assign lhs, s(:svalue, rhs).line(rhs.line)
225
226
  }
226
227
  | mlhs tEQL mrhs_arg kRESCUE_MOD stmt
@@ -407,6 +408,7 @@ rule
407
408
  defs_head: k_def singleton dot_or_colon
408
409
  {
409
410
  lexer.lex_state = EXPR_FNAME
411
+ self.in_argdef = true
410
412
  }
411
413
  def_name
412
414
  {
@@ -620,7 +622,7 @@ rule
620
622
  }
621
623
  | tSTAR
622
624
  {
623
- l = lexer.lineno
625
+ (_, l), = val
624
626
  result = s(:masgn, s(:array, s(:splat).line(l)).line(l)).line l
625
627
  }
626
628
  | tSTAR tCOMMA mlhs_post
@@ -1130,8 +1132,10 @@ rule
1130
1132
 
1131
1133
  paren_args: tLPAREN2 opt_call_args rparen
1132
1134
  {
1133
- _, args, _ = val
1135
+ _, args, (_, line_max) = val
1136
+
1134
1137
  result = args
1138
+ result.line_max = line_max if args
1135
1139
  }
1136
1140
  | tLPAREN2 args tCOMMA args_forward rparen
1137
1141
  {
@@ -1248,7 +1252,7 @@ rule
1248
1252
  args: arg_value
1249
1253
  {
1250
1254
  arg, = val
1251
- lineno = arg.line || lexer.lineno # HACK
1255
+ lineno = arg.line
1252
1256
 
1253
1257
  result = s(:array, arg).line lineno
1254
1258
  }
@@ -1264,9 +1268,7 @@ rule
1264
1268
  }
1265
1269
  | args tCOMMA tSTAR arg_value
1266
1270
  {
1267
- # TODO: the line number from tSTAR has been dropped
1268
- args, _, _, id = val
1269
- line = lexer.lineno
1271
+ args, _, (_, line), id = val
1270
1272
  result = self.list_append args, s(:splat, id).line(line)
1271
1273
  }
1272
1274
 
@@ -1285,7 +1287,6 @@ rule
1285
1287
  }
1286
1288
  | args tCOMMA tSTAR arg_value
1287
1289
  {
1288
- # TODO: make all tXXXX terminals include lexer.lineno
1289
1290
  arg, _, _, splat = val
1290
1291
  result = self.arg_concat arg, splat
1291
1292
  }
@@ -1314,7 +1315,6 @@ rule
1314
1315
  | k_begin
1315
1316
  {
1316
1317
  lexer.cmdarg.push false
1317
- result = self.lexer.lineno
1318
1318
  }
1319
1319
  bodystmt k_end
1320
1320
  {
@@ -1324,11 +1324,10 @@ rule
1324
1324
  | tLPAREN_ARG
1325
1325
  {
1326
1326
  lexer.lex_state = EXPR_ENDARG
1327
- result = lexer.lineno
1328
1327
  }
1329
1328
  rparen
1330
1329
  {
1331
- _, line, _ = val
1330
+ (_, line), _, _ = val
1332
1331
  result = s(:begin).line line
1333
1332
  }
1334
1333
  | tLPAREN_ARG
@@ -1344,9 +1343,8 @@ rule
1344
1343
  }
1345
1344
  | tLPAREN compstmt tRPAREN
1346
1345
  {
1347
- _, stmt, _ = val
1348
- result = stmt
1349
- result ||= s(:nil).line lexer.lineno
1346
+ (_, line), stmt, _ = val
1347
+ result = stmt || s(:nil).line(line)
1350
1348
  result.paren = true
1351
1349
  }
1352
1350
  | primary_value tCOLON2 tCONSTANT
@@ -1359,12 +1357,14 @@ rule
1359
1357
  {
1360
1358
  result = wrap :colon3, val[1]
1361
1359
  }
1362
- | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1360
+ | tLBRACK aref_args rbracket
1363
1361
  {
1364
- _, line, args, _ = val
1362
+ (_, line), args, (_, line_max) = val
1363
+
1365
1364
  result = args || s(:array)
1366
1365
  result.sexp_type = :array # aref_args is :args
1367
1366
  result.line line
1367
+ result.line_max = line_max
1368
1368
  }
1369
1369
  | tLBRACE
1370
1370
  {
@@ -1475,9 +1475,6 @@ rule
1475
1475
  result = new_for iter, var, body
1476
1476
  }
1477
1477
  | k_class
1478
- {
1479
- result = self.lexer.lineno
1480
- }
1481
1478
  cpath superclass
1482
1479
  {
1483
1480
  if (self.in_def || self.in_single > 0) then
@@ -1492,9 +1489,6 @@ rule
1492
1489
  self.lexer.ignore_body_comments
1493
1490
  }
1494
1491
  | k_class tLSHFT
1495
- {
1496
- result = self.lexer.lineno
1497
- }
1498
1492
  expr
1499
1493
  {
1500
1494
  result = self.in_def
@@ -1506,16 +1500,14 @@ rule
1506
1500
  self.in_single = 0
1507
1501
  self.env.extend
1508
1502
  }
1509
- bodystmt k_end
1503
+ bodystmt
1504
+ k_end
1510
1505
  {
1511
1506
  result = new_sclass val
1512
1507
  self.env.unextend
1513
1508
  self.lexer.ignore_body_comments
1514
1509
  }
1515
1510
  | k_module
1516
- {
1517
- result = self.lexer.lineno
1518
- }
1519
1511
  cpath
1520
1512
  {
1521
1513
  yyerror "module definition in method body" if
@@ -1618,6 +1610,7 @@ rule
1618
1610
  k_def: kDEF
1619
1611
  {
1620
1612
  self.comments.push self.lexer.comments
1613
+ self.in_argdef = true
1621
1614
  }
1622
1615
  k_do: kDO
1623
1616
  k_do_block: kDO_BLOCK
@@ -1657,20 +1650,33 @@ rule
1657
1650
  }
1658
1651
 
1659
1652
  f_marg: f_norm_arg
1653
+ {
1654
+ (sym, line), = val
1655
+
1656
+ result = s(:dummy, sym).line line
1657
+ }
1660
1658
  | tLPAREN f_margs rparen
1661
1659
  {
1662
- result = val[1]
1660
+ _, args, _ = val
1661
+ result = args
1663
1662
  }
1664
1663
 
1665
1664
  f_marg_list: f_marg
1666
1665
  {
1667
- sym, = val
1666
+ arg, = val
1667
+ line = arg.line
1668
+
1669
+ arg = arg.last if arg.sexp_type == :dummy
1668
1670
 
1669
- result = s(:array, sym).line lexer.lineno
1671
+ result = s(:array, arg).line line
1670
1672
  }
1671
1673
  | f_marg_list tCOMMA f_marg
1672
1674
  {
1673
- result = list_append val[0], val[2]
1675
+ args, _, arg = val
1676
+
1677
+ arg = arg.last if arg.sexp_type == :dummy
1678
+
1679
+ result = list_append args, arg
1674
1680
  }
1675
1681
 
1676
1682
  f_margs: f_marg_list
@@ -1713,14 +1719,14 @@ rule
1713
1719
  }
1714
1720
  | tSTAR
1715
1721
  {
1716
- result = args [:*]
1717
- result.line lexer.lineno # FIX: tSTAR -> line
1722
+ (_, line), = val
1723
+ result = args([:*]).line line
1718
1724
  }
1719
1725
 
1720
1726
  f_any_kwrest: f_kwrest
1721
1727
  | f_no_kwarg
1722
1728
 
1723
- f_eq: tEQL # TODO: self.in_argdef = false
1729
+ f_eq: { self.in_argdef = false } tEQL
1724
1730
 
1725
1731
  block_args_tail: f_block_kwarg tCOMMA f_kwrest opt_f_block_arg
1726
1732
  {
@@ -1824,15 +1830,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1824
1830
  {
1825
1831
  # TODO: current_arg = 0
1826
1832
  result = args val
1833
+ self.in_argdef = false
1827
1834
  }
1828
1835
  | tOROP
1829
1836
  {
1830
- result = s(:args).line lexer.lineno
1837
+ (_, line), = val
1838
+
1839
+ result = s(:args).line line
1831
1840
  }
1832
1841
  | tPIPE block_param opt_bv_decl tPIPE
1833
1842
  {
1834
1843
  # TODO: current_arg = 0
1835
1844
  result = args val
1845
+ self.in_argdef = false
1836
1846
  }
1837
1847
 
1838
1848
  opt_bv_decl: opt_nl
@@ -1859,7 +1869,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1859
1869
  lambda: tLAMBDA
1860
1870
  {
1861
1871
  self.env.extend :dynamic
1862
- result = [lexer.lineno, lexer.lpar_beg]
1872
+ result = lexer.lpar_beg
1863
1873
  lexer.paren_nest += 1
1864
1874
  lexer.lpar_beg = lexer.paren_nest
1865
1875
  }
@@ -1869,7 +1879,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1869
1879
  }
1870
1880
  lambda_body
1871
1881
  {
1872
- _, (line, lpar), args, _cmdarg, body = val
1882
+ (_, line), lpar, args, _cmdarg, body = val
1873
1883
  lexer.lpar_beg = lpar
1874
1884
 
1875
1885
  lexer.cmdarg.pop
@@ -1882,10 +1892,12 @@ opt_block_args_tail: tCOMMA block_args_tail
1882
1892
 
1883
1893
  f_larglist: tLPAREN2 f_args opt_bv_decl rparen
1884
1894
  {
1895
+ self.in_argdef = false
1885
1896
  result = args val
1886
1897
  }
1887
1898
  | f_args
1888
1899
  {
1900
+ self.in_argdef = false
1889
1901
  result = val[0]
1890
1902
  result = 0 if result == s(:args)
1891
1903
  }
@@ -1953,13 +1965,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1953
1965
  {
1954
1966
  call, args = val
1955
1967
 
1956
- result = call.concat args.sexp_body if args
1968
+ result = call
1969
+
1970
+ if args then
1971
+ call.concat args.sexp_body
1972
+ result.line_max = args.line_max
1973
+ end
1957
1974
  }
1958
1975
  | primary_value call_op operation2 opt_paren_args
1959
1976
  {
1960
- recv, call_op, (op, _line), args = val
1977
+ recv, call_op, (op, op_line), args = val
1961
1978
 
1962
1979
  result = new_call recv, op.to_sym, args, call_op
1980
+ result.line_max = op_line unless args
1963
1981
  }
1964
1982
  | primary_value tCOLON2 operation2 paren_args
1965
1983
  {
@@ -1987,7 +2005,8 @@ opt_block_args_tail: tCOMMA block_args_tail
1987
2005
  }
1988
2006
  | kSUPER
1989
2007
  {
1990
- result = s(:zsuper).line lexer.lineno
2008
+ (_, line), = val
2009
+ result = s(:zsuper).line line
1991
2010
  }
1992
2011
  | primary_value tLBRACK2 opt_call_args rbracket
1993
2012
  {
@@ -1997,11 +2016,11 @@ opt_block_args_tail: tCOMMA block_args_tail
1997
2016
  brace_block: tLCURLY
1998
2017
  {
1999
2018
  self.env.extend :dynamic
2000
- result = self.lexer.lineno
2001
2019
  }
2002
- brace_body tRCURLY
2020
+ brace_body
2021
+ tRCURLY
2003
2022
  {
2004
- _, line, body, _ = val
2023
+ (_, line), _, body, _ = val
2005
2024
 
2006
2025
  result = body
2007
2026
  result.line line
@@ -2011,11 +2030,11 @@ opt_block_args_tail: tCOMMA block_args_tail
2011
2030
  | k_do
2012
2031
  {
2013
2032
  self.env.extend :dynamic
2014
- result = self.lexer.lineno
2015
2033
  }
2016
- do_body kEND
2034
+ do_body
2035
+ kEND
2017
2036
  {
2018
- _, line, body, _ = val
2037
+ (_, line), _, body, _ = val
2019
2038
 
2020
2039
  result = body
2021
2040
  result.line line
@@ -2073,14 +2092,13 @@ opt_block_args_tail: tCOMMA block_args_tail
2073
2092
  }
2074
2093
 
2075
2094
  case_body: k_when
2076
- {
2077
- result = self.lexer.lineno
2078
- }
2079
2095
  case_args then compstmt cases
2080
2096
  {
2081
- result = new_when(val[2], val[4])
2082
- result.line val[1]
2083
- result << val[5] if val[5]
2097
+ (_, line), case_args, _then, body, cases = val
2098
+
2099
+ result = new_when case_args, body
2100
+ result.line line
2101
+ result << cases if cases
2084
2102
  }
2085
2103
 
2086
2104
  cases: opt_else | case_body
@@ -2716,15 +2734,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2716
2734
 
2717
2735
  words: tWORDS_BEG tSPACE tSTRING_END
2718
2736
  {
2719
- (_, line), _, _ = val
2737
+ (_, line), _, (_, line_max) = val
2720
2738
 
2721
2739
  result = s(:array).line line
2740
+ result.line_max = line_max
2722
2741
  }
2723
2742
  | tWORDS_BEG word_list tSTRING_END
2724
2743
  {
2725
- (_, line), list, _ = val
2744
+ (_, line), list, (_, line_max) = val
2726
2745
 
2727
2746
  result = list.line line
2747
+ result.line_max = line_max
2728
2748
  }
2729
2749
 
2730
2750
  word_list: none
@@ -2744,15 +2764,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2744
2764
 
2745
2765
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2746
2766
  {
2747
- (_, line), _, _ = val
2767
+ (_, line), _, (_, line_max) = val
2748
2768
 
2749
2769
  result = s(:array).line line
2770
+ result.line_max = line_max
2750
2771
  }
2751
2772
  | tSYMBOLS_BEG symbol_list tSTRING_END
2752
2773
  {
2753
- (_, line), list, _, = val
2754
- list.line line
2755
- result = list
2774
+ (_, line), list, (_, line_max), = val
2775
+
2776
+ result = list.line line
2777
+ result.line_max = line_max
2756
2778
  }
2757
2779
 
2758
2780
  symbol_list: none
@@ -2767,28 +2789,32 @@ opt_block_args_tail: tCOMMA block_args_tail
2767
2789
 
2768
2790
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2769
2791
  {
2770
- (_, line), _, _ = val
2792
+ (_, line), _, (_, line_max) = val
2771
2793
 
2772
2794
  result = s(:array).line line
2795
+ result.line_max = line_max
2773
2796
  }
2774
2797
  | tQWORDS_BEG qword_list tSTRING_END
2775
2798
  {
2776
- (_, line), list, _ = val
2799
+ (_, line), list, (_, line_max) = val
2777
2800
 
2778
2801
  result = list.line line
2802
+ result.line_max = line_max
2779
2803
  }
2780
2804
 
2781
2805
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2782
2806
  {
2783
- (_, line), _, _ = val
2807
+ (_, line), _, (_, line_max) = val
2784
2808
 
2785
2809
  result = s(:array).line line
2810
+ result.line_max = line_max
2786
2811
  }
2787
2812
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2788
2813
  {
2789
- (_, line), list, _ = val
2814
+ (_, line), list, (_, line_max) = val
2790
2815
 
2791
2816
  result = list.line line
2817
+ result.line_max = line_max
2792
2818
  }
2793
2819
 
2794
2820
  qword_list: none
@@ -2863,7 +2889,6 @@ regexp_contents: none
2863
2889
  lexer.brace_nest,
2864
2890
  lexer.string_nest, # TODO: remove
2865
2891
  lexer.lex_state,
2866
- lexer.lineno,
2867
2892
  ]
2868
2893
 
2869
2894
  lexer.cmdarg.push false
@@ -2878,9 +2903,9 @@ regexp_contents: none
2878
2903
  compstmt
2879
2904
  tSTRING_DEND
2880
2905
  {
2881
- _, memo, stmt, _ = val
2906
+ (_, line), memo, stmt, _ = val
2882
2907
 
2883
- lex_strterm, brace_nest, string_nest, oldlex_state, line = memo
2908
+ lex_strterm, brace_nest, string_nest, oldlex_state = memo
2884
2909
  # TODO: heredoc_indent
2885
2910
 
2886
2911
  lexer.lex_strterm = lex_strterm
@@ -2940,11 +2965,11 @@ regexp_contents: none
2940
2965
 
2941
2966
  dsym: tSYMBEG string_contents tSTRING_END
2942
2967
  {
2943
- _, result, _ = val
2968
+ (_, line), result, _ = val
2944
2969
 
2945
2970
  lexer.lex_state = EXPR_END
2946
2971
 
2947
- result ||= s(:str, "").line lexer.lineno
2972
+ result ||= s(:str, "").line line
2948
2973
 
2949
2974
  case result.sexp_type
2950
2975
  when :dstr then
@@ -2980,15 +3005,15 @@ regexp_contents: none
2980
3005
  | tCONSTANT
2981
3006
  | tCVAR
2982
3007
 
2983
- keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2984
- | kSELF { result = s(:self).line lexer.lineno }
2985
- | kTRUE { result = s(:true).line lexer.lineno }
2986
- | kFALSE { result = s(:false).line lexer.lineno }
2987
- | k__FILE__ { result = s(:str, self.file).line lexer.lineno }
2988
- | k__LINE__ { result = s(:lit, lexer.lineno).line lexer.lineno }
3008
+ keyword_variable: kNIL { (_, line), = val; result = s(:nil).line line }
3009
+ | kSELF { (_, line), = val; result = s(:self).line line }
3010
+ | kTRUE { (_, line), = val; result = s(:true).line line }
3011
+ | kFALSE { (_, line), = val; result = s(:false).line line }
3012
+ | k__FILE__ { (_, line), = val; result = s(:str, self.file).line line }
3013
+ | k__LINE__ { (_, line), = val; result = s(:lit, line).line line }
2989
3014
  | k__ENCODING__
2990
3015
  {
2991
- l = lexer.lineno
3016
+ (_, l), = val
2992
3017
  result =
2993
3018
  if defined? Encoding then
2994
3019
  s(:colon2, s(:const, :Encoding).line(l), :UTF_8).line l
@@ -3049,11 +3074,13 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
3049
3074
  f_opt_paren_args: f_paren_args
3050
3075
  | none
3051
3076
  {
3077
+ self.in_argdef = false
3052
3078
  result = end_args val
3053
3079
  }
3054
3080
 
3055
3081
  f_paren_args: tLPAREN2 f_args rparen
3056
3082
  {
3083
+ self.in_argdef = false
3057
3084
  result = end_args val
3058
3085
  }
3059
3086
 
@@ -3061,10 +3088,12 @@ f_opt_paren_args: f_paren_args
3061
3088
  | {
3062
3089
  result = self.in_kwarg
3063
3090
  self.in_kwarg = true
3091
+ self.in_argdef = true
3064
3092
  self.lexer.lex_state |= EXPR_LABEL
3065
3093
  }
3066
3094
  f_args term
3067
3095
  {
3096
+ self.in_argdef = false
3068
3097
  result = end_args val
3069
3098
  }
3070
3099
 
@@ -3151,12 +3180,12 @@ f_opt_paren_args: f_paren_args
3151
3180
  |
3152
3181
  {
3153
3182
  result = args val
3154
- # result.line lexer.lineno
3155
3183
  }
3156
3184
 
3157
3185
  args_forward: tBDOT3
3158
3186
  {
3159
- result = s(:forward_args).line lexer.lineno
3187
+ (_, line), = val
3188
+ result = s(:forward_args).line line
3160
3189
  }
3161
3190
 
3162
3191
  f_bad_arg: tCONSTANT
@@ -3210,10 +3239,25 @@ f_opt_paren_args: f_paren_args
3210
3239
  result = s(:args, list).line list.line
3211
3240
  end
3212
3241
 
3213
- result << (Sexp === item ? item : item.first)
3242
+ if Sexp === item then
3243
+ line_max = item.line_max
3244
+ else
3245
+ item, line_max = item
3246
+ end
3247
+
3248
+ result << item
3249
+ result.line_max = line_max
3214
3250
  }
3215
3251
 
3216
3252
  f_label: tLABEL
3253
+ {
3254
+ label, = val
3255
+ # arg_var(p, formal_argument(p, $1));
3256
+ # p->cur_arg = get_id($1);
3257
+ # p->max_numparam = ORDINAL_PARAM;
3258
+ self.in_argdef = false
3259
+ result = label
3260
+ }
3217
3261
 
3218
3262
  f_kw: f_label arg_value
3219
3263
  {
@@ -3222,6 +3266,7 @@ f_opt_paren_args: f_paren_args
3222
3266
 
3223
3267
  identifier = label.to_sym
3224
3268
  self.env[identifier] = :lvar
3269
+ self.in_argdef = true
3225
3270
 
3226
3271
  kwarg = s(:kwarg, identifier, arg).line line
3227
3272
  result = s(:array, kwarg).line line
@@ -3232,6 +3277,7 @@ f_opt_paren_args: f_paren_args
3232
3277
 
3233
3278
  id = label.to_sym
3234
3279
  self.env[id] = :lvar
3280
+ self.in_argdef = true
3235
3281
 
3236
3282
  result = s(:array, s(:kwarg, id).line(line)).line line
3237
3283
  }
@@ -3242,6 +3288,7 @@ f_opt_paren_args: f_paren_args
3242
3288
  (label, line), expr = val
3243
3289
  id = label.to_sym
3244
3290
  self.env[id] = :lvar
3291
+ self.in_argdef = true
3245
3292
 
3246
3293
  result = s(:array, s(:kwarg, id, expr).line(line)).line line
3247
3294
  }
@@ -3251,6 +3298,7 @@ f_opt_paren_args: f_paren_args
3251
3298
  (label, line), = val
3252
3299
  id = label.to_sym
3253
3300
  self.env[id] = :lvar
3301
+ self.in_argdef = true
3254
3302
 
3255
3303
  result = s(:array, s(:kwarg, id).line(line)).line line
3256
3304
  }
@@ -3287,9 +3335,10 @@ f_opt_paren_args: f_paren_args
3287
3335
  }
3288
3336
  | kwrest_mark
3289
3337
  {
3338
+ (_, line), = val
3290
3339
  id = :"**"
3291
- self.env[id] = :lvar # TODO: needed?!?
3292
- result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
3340
+ self.env[id] = :lvar
3341
+ result = [id, line]
3293
3342
  }
3294
3343
 
3295
3344
  f_opt: f_arg_asgn
@@ -3297,10 +3346,10 @@ f_opt_paren_args: f_paren_args
3297
3346
  arg_value
3298
3347
  {
3299
3348
  lhs, _, rhs = val
3349
+ self.in_argdef = true
3300
3350
  result = self.assignable lhs, rhs
3301
3351
  # TODO: detect duplicate names
3302
3352
  # TODO? p->cur_arg = 0;
3303
- # TODO? p->ctxt.in_argdef = 1;
3304
3353
  }
3305
3354
 
3306
3355
  f_block_opt: f_arg_asgn
@@ -3308,9 +3357,9 @@ f_opt_paren_args: f_paren_args
3308
3357
  primary_value
3309
3358
  {
3310
3359
  lhs, _, rhs = val
3360
+ self.in_argdef = true
3311
3361
  result = self.assignable lhs, rhs
3312
3362
  # TODO? p->cur_arg = 0;
3313
- # TODO? p->ctxt.in_argdef = 1;
3314
3363
  }
3315
3364
 
3316
3365
  f_block_optarg: f_block_opt
@@ -3347,9 +3396,10 @@ f_opt_paren_args: f_paren_args
3347
3396
  }
3348
3397
  | restarg_mark
3349
3398
  {
3399
+ (_, line), = val
3350
3400
  name = :"*"
3351
3401
  self.env[name] = :lvar
3352
- result = [name, lexer.lineno] # FIX: tSTAR to include lineno
3402
+ result = [name, line]
3353
3403
  }
3354
3404
 
3355
3405
  blkarg_mark: tAMPER2 | tAMPER
@@ -3454,11 +3504,10 @@ f_opt_paren_args: f_paren_args
3454
3504
  opt_terms: | terms
3455
3505
  opt_nl: | tNL
3456
3506
  rparen: opt_nl tRPAREN
3457
- # TODO:
3458
- # {
3459
- # _, close = val
3460
- # result = [close, lexer.lineno]
3461
- # }
3507
+ {
3508
+ _, close = val # TODO: include lineno in close?
3509
+ result = [close, lexer.lineno]
3510
+ }
3462
3511
  rbracket: opt_nl tRBRACK
3463
3512
  {
3464
3513
  _, close = val