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
@@ -391,6 +392,7 @@ rule
391
392
  defs_head: k_def singleton dot_or_colon
392
393
  {
393
394
  lexer.lex_state = EXPR_FNAME
395
+ self.in_argdef = true
394
396
  }
395
397
  def_name
396
398
  {
@@ -604,7 +606,7 @@ rule
604
606
  }
605
607
  | tSTAR
606
608
  {
607
- l = lexer.lineno
609
+ (_, l), = val
608
610
  result = s(:masgn, s(:array, s(:splat).line(l)).line(l)).line l
609
611
  }
610
612
  | tSTAR tCOMMA mlhs_post
@@ -1114,8 +1116,10 @@ rule
1114
1116
 
1115
1117
  paren_args: tLPAREN2 opt_call_args rparen
1116
1118
  {
1117
- _, args, _ = val
1119
+ _, args, (_, line_max) = val
1120
+
1118
1121
  result = args
1122
+ result.line_max = line_max if args
1119
1123
  }
1120
1124
  | tLPAREN2 args tCOMMA args_forward rparen
1121
1125
  {
@@ -1227,7 +1231,7 @@ rule
1227
1231
  args: arg_value
1228
1232
  {
1229
1233
  arg, = val
1230
- lineno = arg.line || lexer.lineno # HACK
1234
+ lineno = arg.line
1231
1235
 
1232
1236
  result = s(:array, arg).line lineno
1233
1237
  }
@@ -1243,9 +1247,7 @@ rule
1243
1247
  }
1244
1248
  | args tCOMMA tSTAR arg_value
1245
1249
  {
1246
- # TODO: the line number from tSTAR has been dropped
1247
- args, _, _, id = val
1248
- line = lexer.lineno
1250
+ args, _, (_, line), id = val
1249
1251
  result = self.list_append args, s(:splat, id).line(line)
1250
1252
  }
1251
1253
 
@@ -1264,7 +1266,6 @@ rule
1264
1266
  }
1265
1267
  | args tCOMMA tSTAR arg_value
1266
1268
  {
1267
- # TODO: make all tXXXX terminals include lexer.lineno
1268
1269
  arg, _, _, splat = val
1269
1270
  result = self.arg_concat arg, splat
1270
1271
  }
@@ -1293,7 +1294,6 @@ rule
1293
1294
  | k_begin
1294
1295
  {
1295
1296
  lexer.cmdarg.push false
1296
- result = self.lexer.lineno
1297
1297
  }
1298
1298
  bodystmt k_end
1299
1299
  {
@@ -1303,11 +1303,10 @@ rule
1303
1303
  | tLPAREN_ARG
1304
1304
  {
1305
1305
  lexer.lex_state = EXPR_ENDARG
1306
- result = lexer.lineno
1307
1306
  }
1308
1307
  rparen
1309
1308
  {
1310
- _, line, _ = val
1309
+ (_, line), _, _ = val
1311
1310
  result = s(:begin).line line
1312
1311
  }
1313
1312
  | tLPAREN_ARG
@@ -1323,9 +1322,8 @@ rule
1323
1322
  }
1324
1323
  | tLPAREN compstmt tRPAREN
1325
1324
  {
1326
- _, stmt, _ = val
1327
- result = stmt
1328
- result ||= s(:nil).line lexer.lineno
1325
+ (_, line), stmt, _ = val
1326
+ result = stmt || s(:nil).line(line)
1329
1327
  result.paren = true
1330
1328
  }
1331
1329
  | primary_value tCOLON2 tCONSTANT
@@ -1338,12 +1336,14 @@ rule
1338
1336
  {
1339
1337
  result = wrap :colon3, val[1]
1340
1338
  }
1341
- | tLBRACK { result = lexer.lineno } aref_args tRBRACK
1339
+ | tLBRACK aref_args rbracket
1342
1340
  {
1343
- _, line, args, _ = val
1341
+ (_, line), args, (_, line_max) = val
1342
+
1344
1343
  result = args || s(:array)
1345
1344
  result.sexp_type = :array # aref_args is :args
1346
1345
  result.line line
1346
+ result.line_max = line_max
1347
1347
  }
1348
1348
  | tLBRACE
1349
1349
  {
@@ -1454,9 +1454,6 @@ rule
1454
1454
  result = new_for iter, var, body
1455
1455
  }
1456
1456
  | k_class
1457
- {
1458
- result = self.lexer.lineno
1459
- }
1460
1457
  cpath superclass
1461
1458
  {
1462
1459
  if (self.in_def || self.in_single > 0) then
@@ -1471,9 +1468,6 @@ rule
1471
1468
  self.lexer.ignore_body_comments
1472
1469
  }
1473
1470
  | k_class tLSHFT
1474
- {
1475
- result = self.lexer.lineno
1476
- }
1477
1471
  expr
1478
1472
  {
1479
1473
  result = self.in_def
@@ -1485,16 +1479,14 @@ rule
1485
1479
  self.in_single = 0
1486
1480
  self.env.extend
1487
1481
  }
1488
- bodystmt k_end
1482
+ bodystmt
1483
+ k_end
1489
1484
  {
1490
1485
  result = new_sclass val
1491
1486
  self.env.unextend
1492
1487
  self.lexer.ignore_body_comments
1493
1488
  }
1494
1489
  | k_module
1495
- {
1496
- result = self.lexer.lineno
1497
- }
1498
1490
  cpath
1499
1491
  {
1500
1492
  yyerror "module definition in method body" if
@@ -1597,6 +1589,7 @@ rule
1597
1589
  k_def: kDEF
1598
1590
  {
1599
1591
  self.comments.push self.lexer.comments
1592
+ self.in_argdef = true
1600
1593
  }
1601
1594
  k_do: kDO
1602
1595
  k_do_block: kDO_BLOCK
@@ -1636,20 +1629,33 @@ rule
1636
1629
  }
1637
1630
 
1638
1631
  f_marg: f_norm_arg
1632
+ {
1633
+ (sym, line), = val
1634
+
1635
+ result = s(:dummy, sym).line line
1636
+ }
1639
1637
  | tLPAREN f_margs rparen
1640
1638
  {
1641
- result = val[1]
1639
+ _, args, _ = val
1640
+ result = args
1642
1641
  }
1643
1642
 
1644
1643
  f_marg_list: f_marg
1645
1644
  {
1646
- sym, = val
1645
+ arg, = val
1646
+ line = arg.line
1647
+
1648
+ arg = arg.last if arg.sexp_type == :dummy
1647
1649
 
1648
- result = s(:array, sym).line lexer.lineno
1650
+ result = s(:array, arg).line line
1649
1651
  }
1650
1652
  | f_marg_list tCOMMA f_marg
1651
1653
  {
1652
- result = list_append val[0], val[2]
1654
+ args, _, arg = val
1655
+
1656
+ arg = arg.last if arg.sexp_type == :dummy
1657
+
1658
+ result = list_append args, arg
1653
1659
  }
1654
1660
 
1655
1661
  f_margs: f_marg_list
@@ -1692,8 +1698,8 @@ rule
1692
1698
  }
1693
1699
  | tSTAR
1694
1700
  {
1695
- result = args [:*]
1696
- result.line lexer.lineno # FIX: tSTAR -> line
1701
+ (_, line), = val
1702
+ result = args([:*]).line line
1697
1703
  }
1698
1704
 
1699
1705
  f_any_kwrest: f_kwrest
@@ -1802,15 +1808,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1802
1808
  {
1803
1809
  # TODO: current_arg = 0
1804
1810
  result = args val
1811
+ self.in_argdef = false
1805
1812
  }
1806
1813
  | tOROP
1807
1814
  {
1808
- result = s(:args).line lexer.lineno
1815
+ (_, line), = val
1816
+
1817
+ result = s(:args).line line
1809
1818
  }
1810
1819
  | tPIPE block_param opt_bv_decl tPIPE
1811
1820
  {
1812
1821
  # TODO: current_arg = 0
1813
1822
  result = args val
1823
+ self.in_argdef = false
1814
1824
  }
1815
1825
 
1816
1826
  opt_bv_decl: opt_nl
@@ -1837,7 +1847,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1837
1847
  lambda: tLAMBDA
1838
1848
  {
1839
1849
  self.env.extend :dynamic
1840
- result = [lexer.lineno, lexer.lpar_beg]
1850
+ result = lexer.lpar_beg
1841
1851
  lexer.paren_nest += 1
1842
1852
  lexer.lpar_beg = lexer.paren_nest
1843
1853
  }
@@ -1847,7 +1857,7 @@ opt_block_args_tail: tCOMMA block_args_tail
1847
1857
  }
1848
1858
  lambda_body
1849
1859
  {
1850
- _, (line, lpar), args, _cmdarg, body = val
1860
+ (_, line), lpar, args, _cmdarg, body = val
1851
1861
  lexer.lpar_beg = lpar
1852
1862
 
1853
1863
  lexer.cmdarg.pop
@@ -1860,10 +1870,12 @@ opt_block_args_tail: tCOMMA block_args_tail
1860
1870
 
1861
1871
  f_larglist: tLPAREN2 f_args opt_bv_decl rparen
1862
1872
  {
1873
+ self.in_argdef = false
1863
1874
  result = args val
1864
1875
  }
1865
1876
  | f_args
1866
1877
  {
1878
+ self.in_argdef = false
1867
1879
  result = val[0]
1868
1880
  result = 0 if result == s(:args)
1869
1881
  }
@@ -1931,13 +1943,19 @@ opt_block_args_tail: tCOMMA block_args_tail
1931
1943
  {
1932
1944
  call, args = val
1933
1945
 
1934
- result = call.concat args.sexp_body if args
1946
+ result = call
1947
+
1948
+ if args then
1949
+ call.concat args.sexp_body
1950
+ result.line_max = args.line_max
1951
+ end
1935
1952
  }
1936
1953
  | primary_value call_op operation2 opt_paren_args
1937
1954
  {
1938
- recv, call_op, (op, _line), args = val
1955
+ recv, call_op, (op, op_line), args = val
1939
1956
 
1940
1957
  result = new_call recv, op.to_sym, args, call_op
1958
+ result.line_max = op_line unless args
1941
1959
  }
1942
1960
  | primary_value tCOLON2 operation2 paren_args
1943
1961
  {
@@ -1965,7 +1983,8 @@ opt_block_args_tail: tCOMMA block_args_tail
1965
1983
  }
1966
1984
  | kSUPER
1967
1985
  {
1968
- result = s(:zsuper).line lexer.lineno
1986
+ (_, line), = val
1987
+ result = s(:zsuper).line line
1969
1988
  }
1970
1989
  | primary_value tLBRACK2 opt_call_args rbracket
1971
1990
  {
@@ -1975,11 +1994,11 @@ opt_block_args_tail: tCOMMA block_args_tail
1975
1994
  brace_block: tLCURLY
1976
1995
  {
1977
1996
  self.env.extend :dynamic
1978
- result = self.lexer.lineno
1979
1997
  }
1980
- brace_body tRCURLY
1998
+ brace_body
1999
+ tRCURLY
1981
2000
  {
1982
- _, line, body, _ = val
2001
+ (_, line), _, body, _ = val
1983
2002
 
1984
2003
  result = body
1985
2004
  result.line line
@@ -1989,11 +2008,11 @@ opt_block_args_tail: tCOMMA block_args_tail
1989
2008
  | k_do
1990
2009
  {
1991
2010
  self.env.extend :dynamic
1992
- result = self.lexer.lineno
1993
2011
  }
1994
- do_body kEND
2012
+ do_body
2013
+ kEND
1995
2014
  {
1996
- _, line, body, _ = val
2015
+ (_, line), _, body, _ = val
1997
2016
 
1998
2017
  result = body
1999
2018
  result.line line
@@ -2051,14 +2070,13 @@ opt_block_args_tail: tCOMMA block_args_tail
2051
2070
  }
2052
2071
 
2053
2072
  case_body: k_when
2054
- {
2055
- result = self.lexer.lineno
2056
- }
2057
2073
  case_args then compstmt cases
2058
2074
  {
2059
- result = new_when(val[2], val[4])
2060
- result.line val[1]
2061
- result << val[5] if val[5]
2075
+ (_, line), case_args, _then, body, cases = val
2076
+
2077
+ result = new_when case_args, body
2078
+ result.line line
2079
+ result << cases if cases
2062
2080
  }
2063
2081
 
2064
2082
  cases: opt_else | case_body
@@ -2678,15 +2696,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2678
2696
 
2679
2697
  words: tWORDS_BEG tSPACE tSTRING_END
2680
2698
  {
2681
- (_, line), _, _ = val
2699
+ (_, line), _, (_, line_max) = val
2682
2700
 
2683
2701
  result = s(:array).line line
2702
+ result.line_max = line_max
2684
2703
  }
2685
2704
  | tWORDS_BEG word_list tSTRING_END
2686
2705
  {
2687
- (_, line), list, _ = val
2706
+ (_, line), list, (_, line_max) = val
2688
2707
 
2689
2708
  result = list.line line
2709
+ result.line_max = line_max
2690
2710
  }
2691
2711
 
2692
2712
  word_list: none
@@ -2706,15 +2726,17 @@ opt_block_args_tail: tCOMMA block_args_tail
2706
2726
 
2707
2727
  symbols: tSYMBOLS_BEG tSPACE tSTRING_END
2708
2728
  {
2709
- (_, line), _, _ = val
2729
+ (_, line), _, (_, line_max) = val
2710
2730
 
2711
2731
  result = s(:array).line line
2732
+ result.line_max = line_max
2712
2733
  }
2713
2734
  | tSYMBOLS_BEG symbol_list tSTRING_END
2714
2735
  {
2715
- (_, line), list, _, = val
2716
- list.line line
2717
- result = list
2736
+ (_, line), list, (_, line_max), = val
2737
+
2738
+ result = list.line line
2739
+ result.line_max = line_max
2718
2740
  }
2719
2741
 
2720
2742
  symbol_list: none
@@ -2729,28 +2751,32 @@ opt_block_args_tail: tCOMMA block_args_tail
2729
2751
 
2730
2752
  qwords: tQWORDS_BEG tSPACE tSTRING_END
2731
2753
  {
2732
- (_, line), _, _ = val
2754
+ (_, line), _, (_, line_max) = val
2733
2755
 
2734
2756
  result = s(:array).line line
2757
+ result.line_max = line_max
2735
2758
  }
2736
2759
  | tQWORDS_BEG qword_list tSTRING_END
2737
2760
  {
2738
- (_, line), list, _ = val
2761
+ (_, line), list, (_, line_max) = val
2739
2762
 
2740
2763
  result = list.line line
2764
+ result.line_max = line_max
2741
2765
  }
2742
2766
 
2743
2767
  qsymbols: tQSYMBOLS_BEG tSPACE tSTRING_END
2744
2768
  {
2745
- (_, line), _, _ = val
2769
+ (_, line), _, (_, line_max) = val
2746
2770
 
2747
2771
  result = s(:array).line line
2772
+ result.line_max = line_max
2748
2773
  }
2749
2774
  | tQSYMBOLS_BEG qsym_list tSTRING_END
2750
2775
  {
2751
- (_, line), list, _ = val
2776
+ (_, line), list, (_, line_max) = val
2752
2777
 
2753
2778
  result = list.line line
2779
+ result.line_max = line_max
2754
2780
  }
2755
2781
 
2756
2782
  qword_list: none
@@ -2825,7 +2851,6 @@ regexp_contents: none
2825
2851
  lexer.brace_nest,
2826
2852
  lexer.string_nest, # TODO: remove
2827
2853
  lexer.lex_state,
2828
- lexer.lineno,
2829
2854
  ]
2830
2855
 
2831
2856
  lexer.cmdarg.push false
@@ -2840,9 +2865,9 @@ regexp_contents: none
2840
2865
  compstmt
2841
2866
  tSTRING_DEND
2842
2867
  {
2843
- _, memo, stmt, _ = val
2868
+ (_, line), memo, stmt, _ = val
2844
2869
 
2845
- lex_strterm, brace_nest, string_nest, oldlex_state, line = memo
2870
+ lex_strterm, brace_nest, string_nest, oldlex_state = memo
2846
2871
  # TODO: heredoc_indent
2847
2872
 
2848
2873
  lexer.lex_strterm = lex_strterm
@@ -2902,11 +2927,11 @@ regexp_contents: none
2902
2927
 
2903
2928
  dsym: tSYMBEG string_contents tSTRING_END
2904
2929
  {
2905
- _, result, _ = val
2930
+ (_, line), result, _ = val
2906
2931
 
2907
2932
  lexer.lex_state = EXPR_END
2908
2933
 
2909
- result ||= s(:str, "").line lexer.lineno
2934
+ result ||= s(:str, "").line line
2910
2935
 
2911
2936
  case result.sexp_type
2912
2937
  when :dstr then
@@ -2939,15 +2964,15 @@ regexp_contents: none
2939
2964
  | tCONSTANT
2940
2965
  | tCVAR
2941
2966
 
2942
- keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
2943
- | kSELF { result = s(:self).line lexer.lineno }
2944
- | kTRUE { result = s(:true).line lexer.lineno }
2945
- | kFALSE { result = s(:false).line lexer.lineno }
2946
- | k__FILE__ { result = s(:str, self.file).line lexer.lineno }
2947
- | k__LINE__ { result = s(:lit, lexer.lineno).line lexer.lineno }
2967
+ keyword_variable: kNIL { (_, line), = val; result = s(:nil).line line }
2968
+ | kSELF { (_, line), = val; result = s(:self).line line }
2969
+ | kTRUE { (_, line), = val; result = s(:true).line line }
2970
+ | kFALSE { (_, line), = val; result = s(:false).line line }
2971
+ | k__FILE__ { (_, line), = val; result = s(:str, self.file).line line }
2972
+ | k__LINE__ { (_, line), = val; result = s(:lit, line).line line }
2948
2973
  | k__ENCODING__
2949
2974
  {
2950
- l = lexer.lineno
2975
+ (_, l), = val
2951
2976
  result =
2952
2977
  if defined? Encoding then
2953
2978
  s(:colon2, s(:const, :Encoding).line(l), :UTF_8).line l
@@ -3008,11 +3033,13 @@ keyword_variable: kNIL { result = s(:nil).line lexer.lineno }
3008
3033
  f_opt_paren_args: f_paren_args
3009
3034
  | none
3010
3035
  {
3036
+ self.in_argdef = false
3011
3037
  result = end_args val
3012
3038
  }
3013
3039
 
3014
3040
  f_paren_args: tLPAREN2 f_args rparen
3015
3041
  {
3042
+ self.in_argdef = false
3016
3043
  result = end_args val
3017
3044
  }
3018
3045
  | tLPAREN2 f_arg tCOMMA args_forward rparen
@@ -3028,10 +3055,12 @@ f_opt_paren_args: f_paren_args
3028
3055
  | {
3029
3056
  result = self.in_kwarg
3030
3057
  self.in_kwarg = true
3058
+ self.in_argdef = true
3031
3059
  self.lexer.lex_state |= EXPR_LABEL
3032
3060
  }
3033
3061
  f_args term
3034
3062
  {
3063
+ self.in_argdef = false
3035
3064
  result = end_args val
3036
3065
  }
3037
3066
 
@@ -3117,12 +3146,12 @@ f_opt_paren_args: f_paren_args
3117
3146
  |
3118
3147
  {
3119
3148
  result = args val
3120
- # result.line lexer.lineno
3121
3149
  }
3122
3150
 
3123
3151
  args_forward: tBDOT3
3124
3152
  {
3125
- result = s(:forward_args).line lexer.lineno
3153
+ (_, line), = val
3154
+ result = s(:forward_args).line line
3126
3155
  }
3127
3156
 
3128
3157
  f_bad_arg: tCONSTANT
@@ -3176,10 +3205,25 @@ f_opt_paren_args: f_paren_args
3176
3205
  result = s(:args, list).line list.line
3177
3206
  end
3178
3207
 
3179
- result << (Sexp === item ? item : item.first)
3208
+ if Sexp === item then
3209
+ line_max = item.line_max
3210
+ else
3211
+ item, line_max = item
3212
+ end
3213
+
3214
+ result << item
3215
+ result.line_max = line_max
3180
3216
  }
3181
3217
 
3182
3218
  f_label: tLABEL
3219
+ {
3220
+ label, = val
3221
+ # arg_var(p, formal_argument(p, $1));
3222
+ # p->cur_arg = get_id($1);
3223
+ # p->max_numparam = ORDINAL_PARAM;
3224
+ self.in_argdef = false
3225
+ result = label
3226
+ }
3183
3227
 
3184
3228
  f_kw: f_label arg_value
3185
3229
  {
@@ -3188,6 +3232,7 @@ f_opt_paren_args: f_paren_args
3188
3232
 
3189
3233
  identifier = label.to_sym
3190
3234
  self.env[identifier] = :lvar
3235
+ self.in_argdef = true
3191
3236
 
3192
3237
  kwarg = s(:kwarg, identifier, arg).line line
3193
3238
  result = s(:array, kwarg).line line
@@ -3198,6 +3243,7 @@ f_opt_paren_args: f_paren_args
3198
3243
 
3199
3244
  id = label.to_sym
3200
3245
  self.env[id] = :lvar
3246
+ self.in_argdef = true
3201
3247
 
3202
3248
  result = s(:array, s(:kwarg, id).line(line)).line line
3203
3249
  }
@@ -3208,6 +3254,7 @@ f_opt_paren_args: f_paren_args
3208
3254
  (label, line), expr = val
3209
3255
  id = label.to_sym
3210
3256
  self.env[id] = :lvar
3257
+ self.in_argdef = true
3211
3258
 
3212
3259
  result = s(:array, s(:kwarg, id, expr).line(line)).line line
3213
3260
  }
@@ -3217,6 +3264,7 @@ f_opt_paren_args: f_paren_args
3217
3264
  (label, line), = val
3218
3265
  id = label.to_sym
3219
3266
  self.env[id] = :lvar
3267
+ self.in_argdef = true
3220
3268
 
3221
3269
  result = s(:array, s(:kwarg, id).line(line)).line line
3222
3270
  }
@@ -3253,9 +3301,10 @@ f_opt_paren_args: f_paren_args
3253
3301
  }
3254
3302
  | kwrest_mark
3255
3303
  {
3304
+ (_, line), = val
3256
3305
  id = :"**"
3257
- self.env[id] = :lvar # TODO: needed?!?
3258
- result = [id, lexer.lineno] # TODO: tPOW/tDSTAR include lineno
3306
+ self.env[id] = :lvar
3307
+ result = [id, line]
3259
3308
  }
3260
3309
 
3261
3310
  f_opt: f_arg_asgn
@@ -3263,10 +3312,10 @@ f_opt_paren_args: f_paren_args
3263
3312
  arg_value
3264
3313
  {
3265
3314
  lhs, _, rhs = val
3315
+ self.in_argdef = true
3266
3316
  result = self.assignable lhs, rhs
3267
3317
  # TODO: detect duplicate names
3268
3318
  # TODO? p->cur_arg = 0;
3269
- # TODO? p->ctxt.in_argdef = 1;
3270
3319
  }
3271
3320
 
3272
3321
  f_block_opt: f_arg_asgn
@@ -3274,9 +3323,9 @@ f_opt_paren_args: f_paren_args
3274
3323
  primary_value
3275
3324
  {
3276
3325
  lhs, _, rhs = val
3326
+ self.in_argdef = true
3277
3327
  result = self.assignable lhs, rhs
3278
3328
  # TODO? p->cur_arg = 0;
3279
- # TODO? p->ctxt.in_argdef = 1;
3280
3329
  }
3281
3330
 
3282
3331
  f_block_optarg: f_block_opt
@@ -3313,9 +3362,10 @@ f_opt_paren_args: f_paren_args
3313
3362
  }
3314
3363
  | restarg_mark
3315
3364
  {
3365
+ (_, line), = val
3316
3366
  name = :"*"
3317
3367
  self.env[name] = :lvar
3318
- result = [name, lexer.lineno] # FIX: tSTAR to include lineno
3368
+ result = [name, line]
3319
3369
  }
3320
3370
 
3321
3371
  blkarg_mark: tAMPER2 | tAMPER
@@ -3420,11 +3470,10 @@ f_opt_paren_args: f_paren_args
3420
3470
  opt_terms: | terms
3421
3471
  opt_nl: | tNL
3422
3472
  rparen: opt_nl tRPAREN
3423
- # TODO:
3424
- # {
3425
- # _, close = val
3426
- # result = [close, lexer.lineno]
3427
- # }
3473
+ {
3474
+ _, close = val # TODO: include lineno in close?
3475
+ result = [close, lexer.lineno]
3476
+ }
3428
3477
  rbracket: opt_nl tRBRACK
3429
3478
  {
3430
3479
  _, close = val