prism 0.26.0 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -1
  3. data/Makefile +3 -2
  4. data/config.yml +305 -20
  5. data/docs/configuration.md +1 -0
  6. data/ext/prism/api_node.c +884 -879
  7. data/ext/prism/extconf.rb +23 -4
  8. data/ext/prism/extension.c +16 -9
  9. data/ext/prism/extension.h +1 -1
  10. data/include/prism/ast.h +298 -9
  11. data/include/prism/diagnostic.h +15 -5
  12. data/include/prism/options.h +2 -2
  13. data/include/prism/parser.h +10 -0
  14. data/include/prism/static_literals.h +8 -6
  15. data/include/prism/version.h +2 -2
  16. data/lib/prism/dot_visitor.rb +22 -6
  17. data/lib/prism/dsl.rb +8 -8
  18. data/lib/prism/ffi.rb +4 -4
  19. data/lib/prism/inspect_visitor.rb +2156 -0
  20. data/lib/prism/lex_compat.rb +18 -1
  21. data/lib/prism/mutation_compiler.rb +2 -2
  22. data/lib/prism/node.rb +2345 -1964
  23. data/lib/prism/node_ext.rb +34 -5
  24. data/lib/prism/parse_result/newlines.rb +0 -2
  25. data/lib/prism/parse_result.rb +137 -13
  26. data/lib/prism/pattern.rb +12 -6
  27. data/lib/prism/polyfill/byteindex.rb +13 -0
  28. data/lib/prism/polyfill/unpack1.rb +14 -0
  29. data/lib/prism/reflection.rb +21 -31
  30. data/lib/prism/serialize.rb +27 -17
  31. data/lib/prism/translation/parser/compiler.rb +34 -15
  32. data/lib/prism/translation/parser.rb +6 -6
  33. data/lib/prism/translation/ripper.rb +72 -68
  34. data/lib/prism/translation/ruby_parser.rb +69 -31
  35. data/lib/prism.rb +3 -2
  36. data/prism.gemspec +36 -38
  37. data/rbi/prism/compiler.rbi +3 -5
  38. data/rbi/prism/inspect_visitor.rbi +12 -0
  39. data/rbi/prism/node.rbi +359 -321
  40. data/rbi/prism/parse_result.rbi +85 -34
  41. data/rbi/prism/reflection.rbi +7 -13
  42. data/rbi/prism/translation/ripper.rbi +1 -11
  43. data/rbi/prism.rbi +9 -9
  44. data/sig/prism/dsl.rbs +3 -3
  45. data/sig/prism/inspect_visitor.rbs +22 -0
  46. data/sig/prism/node.rbs +68 -48
  47. data/sig/prism/parse_result.rbs +42 -10
  48. data/sig/prism/reflection.rbs +2 -8
  49. data/sig/prism/serialize.rbs +2 -3
  50. data/sig/prism.rbs +9 -9
  51. data/src/diagnostic.c +44 -24
  52. data/src/node.c +41 -16
  53. data/src/options.c +2 -2
  54. data/src/prettyprint.c +61 -18
  55. data/src/prism.c +623 -188
  56. data/src/serialize.c +5 -2
  57. data/src/static_literals.c +120 -34
  58. data/src/token_type.c +4 -4
  59. data/src/util/pm_integer.c +9 -2
  60. metadata +7 -9
  61. data/lib/prism/node_inspector.rb +0 -68
  62. data/lib/prism/polyfill/string.rb +0 -12
  63. data/rbi/prism/desugar_compiler.rbi +0 -5
  64. data/rbi/prism/mutation_compiler.rbi +0 -5
  65. data/rbi/prism/translation/parser/compiler.rbi +0 -13
  66. data/rbi/prism/translation/ripper/ripper_compiler.rbi +0 -5
  67. data/rbi/prism/translation/ruby_parser.rbi +0 -11
data/include/prism/ast.h CHANGED
@@ -1099,16 +1099,31 @@ typedef struct pm_alias_global_variable_node {
1099
1099
 
1100
1100
  /**
1101
1101
  * AliasGlobalVariableNode#new_name
1102
+ *
1103
+ * Represents the new name of the global variable that can be used after aliasing. This can be either a global variable, a back reference, or a numbered reference.
1104
+ *
1105
+ * alias $foo $bar
1106
+ * ^^^^
1102
1107
  */
1103
1108
  struct pm_node *new_name;
1104
1109
 
1105
1110
  /**
1106
1111
  * AliasGlobalVariableNode#old_name
1112
+ *
1113
+ * Represents the old name of the global variable that could be used before aliasing. This can be either a global variable, a back reference, or a numbered reference.
1114
+ *
1115
+ * alias $foo $bar
1116
+ * ^^^^
1107
1117
  */
1108
1118
  struct pm_node *old_name;
1109
1119
 
1110
1120
  /**
1111
1121
  * AliasGlobalVariableNode#keyword_loc
1122
+ *
1123
+ * The location of the `alias` keyword.
1124
+ *
1125
+ * alias $foo $bar
1126
+ * ^^^^^
1112
1127
  */
1113
1128
  pm_location_t keyword_loc;
1114
1129
  } pm_alias_global_variable_node_t;
@@ -1220,6 +1235,7 @@ typedef struct pm_and_node {
1220
1235
  *
1221
1236
  * Type: PM_ARGUMENTS_NODE
1222
1237
  * Flags:
1238
+ * PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORDS
1223
1239
  * PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT
1224
1240
  *
1225
1241
  * @extends pm_node_t
@@ -1249,16 +1265,32 @@ typedef struct pm_array_node {
1249
1265
 
1250
1266
  /**
1251
1267
  * ArrayNode#elements
1268
+ *
1269
+ * Represent the list of zero or more [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression) within the array.
1252
1270
  */
1253
1271
  struct pm_node_list elements;
1254
1272
 
1255
1273
  /**
1256
1274
  * ArrayNode#opening_loc
1275
+ *
1276
+ * Represents the optional source location for the opening token.
1277
+ *
1278
+ * [1,2,3] # "["
1279
+ * %w[foo bar baz] # "%w["
1280
+ * %I(apple orange banana) # "%I("
1281
+ * foo = 1, 2, 3 # nil
1257
1282
  */
1258
1283
  pm_location_t opening_loc;
1259
1284
 
1260
1285
  /**
1261
1286
  * ArrayNode#closing_loc
1287
+ *
1288
+ * Represents the optional source location for the closing token.
1289
+ *
1290
+ * [1,2,3] # "]"
1291
+ * %w[foo bar baz] # "]"
1292
+ * %I(apple orange banana) # ")"
1293
+ * foo = 1, 2, 3 # nil
1262
1294
  */
1263
1295
  pm_location_t closing_loc;
1264
1296
  } pm_array_node_t;
@@ -1605,11 +1637,21 @@ typedef struct pm_break_node {
1605
1637
 
1606
1638
  /**
1607
1639
  * BreakNode#arguments
1640
+ *
1641
+ * The arguments to the break statement, if present. These can be any [non-void expressions](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
1642
+ *
1643
+ * break foo
1644
+ * ^^^
1608
1645
  */
1609
1646
  struct pm_arguments_node *arguments;
1610
1647
 
1611
1648
  /**
1612
1649
  * BreakNode#keyword_loc
1650
+ *
1651
+ * The location of the `break` keyword.
1652
+ *
1653
+ * break foo
1654
+ * ^^^^^
1613
1655
  */
1614
1656
  pm_location_t keyword_loc;
1615
1657
  } pm_break_node_t;
@@ -2209,8 +2251,7 @@ typedef struct pm_class_variable_write_node {
2209
2251
  /**
2210
2252
  * ClassVariableWriteNode#value
2211
2253
  *
2212
- * The value to assign to the class variable. Can be any node that
2213
- * represents a non-void expression.
2254
+ * The value to write to the class variable. This can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
2214
2255
  *
2215
2256
  * @@foo = :bar
2216
2257
  * ^^^^
@@ -2372,18 +2413,52 @@ typedef struct pm_constant_path_node {
2372
2413
 
2373
2414
  /**
2374
2415
  * ConstantPathNode#parent
2416
+ *
2417
+ * The left-hand node of the path, if present. It can be `nil` or any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression). It will be `nil` when the constant lookup is at the root of the module tree.
2418
+ *
2419
+ * Foo::Bar
2420
+ * ^^^
2421
+ *
2422
+ * self::Test
2423
+ * ^^^^
2424
+ *
2425
+ * a.b::C
2426
+ * ^^^
2375
2427
  */
2376
2428
  struct pm_node *parent;
2377
2429
 
2378
2430
  /**
2379
- * ConstantPathNode#child
2431
+ * ConstantPathNode#name
2432
+ *
2433
+ * The name of the constant being accessed. This could be `nil` in the event of a syntax error.
2380
2434
  */
2381
- struct pm_node *child;
2435
+ pm_constant_id_t name;
2382
2436
 
2383
2437
  /**
2384
2438
  * ConstantPathNode#delimiter_loc
2439
+ *
2440
+ * The location of the `::` delimiter.
2441
+ *
2442
+ * ::Foo
2443
+ * ^^
2444
+ *
2445
+ * One::Two
2446
+ * ^^
2385
2447
  */
2386
2448
  pm_location_t delimiter_loc;
2449
+
2450
+ /**
2451
+ * ConstantPathNode#name_loc
2452
+ *
2453
+ * The location of the name of the constant.
2454
+ *
2455
+ * ::Foo
2456
+ * ^^^
2457
+ *
2458
+ * One::Two
2459
+ * ^^^
2460
+ */
2461
+ pm_location_t name_loc;
2387
2462
  } pm_constant_path_node_t;
2388
2463
 
2389
2464
  /**
@@ -2462,14 +2537,19 @@ typedef struct pm_constant_path_target_node {
2462
2537
  struct pm_node *parent;
2463
2538
 
2464
2539
  /**
2465
- * ConstantPathTargetNode#child
2540
+ * ConstantPathTargetNode#name
2466
2541
  */
2467
- struct pm_node *child;
2542
+ pm_constant_id_t name;
2468
2543
 
2469
2544
  /**
2470
2545
  * ConstantPathTargetNode#delimiter_loc
2471
2546
  */
2472
2547
  pm_location_t delimiter_loc;
2548
+
2549
+ /**
2550
+ * ConstantPathTargetNode#name_loc
2551
+ */
2552
+ pm_location_t name_loc;
2473
2553
  } pm_constant_path_target_node_t;
2474
2554
 
2475
2555
  /**
@@ -2485,16 +2565,34 @@ typedef struct pm_constant_path_write_node {
2485
2565
 
2486
2566
  /**
2487
2567
  * ConstantPathWriteNode#target
2568
+ *
2569
+ * A node representing the constant path being written to.
2570
+ *
2571
+ * Foo::Bar = 1
2572
+ * ^^^^^^^^
2573
+ *
2574
+ * ::Foo = :abc
2575
+ * ^^^^^
2488
2576
  */
2489
2577
  struct pm_constant_path_node *target;
2490
2578
 
2491
2579
  /**
2492
2580
  * ConstantPathWriteNode#operator_loc
2581
+ *
2582
+ * The location of the `=` operator.
2583
+ *
2584
+ * ::ABC = 123
2585
+ * ^
2493
2586
  */
2494
2587
  pm_location_t operator_loc;
2495
2588
 
2496
2589
  /**
2497
2590
  * ConstantPathWriteNode#value
2591
+ *
2592
+ * The value to write to the constant path. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
2593
+ *
2594
+ * FOO::BAR = :abc
2595
+ * ^^^^
2498
2596
  */
2499
2597
  struct pm_node *value;
2500
2598
  } pm_constant_path_write_node_t;
@@ -2552,21 +2650,45 @@ typedef struct pm_constant_write_node {
2552
2650
 
2553
2651
  /**
2554
2652
  * ConstantWriteNode#name
2653
+ *
2654
+ * The name of the [constant](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#constants).
2655
+ *
2656
+ * Foo = :bar # name `:Foo`
2657
+ *
2658
+ * XYZ = 1 # name `:XYZ`
2555
2659
  */
2556
2660
  pm_constant_id_t name;
2557
2661
 
2558
2662
  /**
2559
2663
  * ConstantWriteNode#name_loc
2664
+ *
2665
+ * The location of the constant name.
2666
+ *
2667
+ * FOO = 1
2668
+ * ^^^
2560
2669
  */
2561
2670
  pm_location_t name_loc;
2562
2671
 
2563
2672
  /**
2564
2673
  * ConstantWriteNode#value
2674
+ *
2675
+ * The value to write to the constant. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
2676
+ *
2677
+ * FOO = :bar
2678
+ * ^^^^
2679
+ *
2680
+ * MyClass = Class.new
2681
+ * ^^^^^^^^^
2565
2682
  */
2566
2683
  struct pm_node *value;
2567
2684
 
2568
2685
  /**
2569
2686
  * ConstantWriteNode#operator_loc
2687
+ *
2688
+ * The location of the `=` operator.
2689
+ *
2690
+ * FOO = :bar
2691
+ * ^
2570
2692
  */
2571
2693
  pm_location_t operator_loc;
2572
2694
  } pm_constant_write_node_t;
@@ -3122,21 +3244,45 @@ typedef struct pm_global_variable_write_node {
3122
3244
 
3123
3245
  /**
3124
3246
  * GlobalVariableWriteNode#name
3247
+ *
3248
+ * The name of the global variable, which is a `$` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifier). Alternatively, it can be one of the special global variables designated by a symbol.
3249
+ *
3250
+ * $foo = :bar # name `:$foo`
3251
+ *
3252
+ * $_Test = 123 # name `:$_Test`
3125
3253
  */
3126
3254
  pm_constant_id_t name;
3127
3255
 
3128
3256
  /**
3129
3257
  * GlobalVariableWriteNode#name_loc
3258
+ *
3259
+ * The location of the global variable's name.
3260
+ *
3261
+ * $foo = :bar
3262
+ * ^^^^
3130
3263
  */
3131
3264
  pm_location_t name_loc;
3132
3265
 
3133
3266
  /**
3134
3267
  * GlobalVariableWriteNode#value
3268
+ *
3269
+ * The value to write to the global variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
3270
+ *
3271
+ * $foo = :bar
3272
+ * ^^^^
3273
+ *
3274
+ * $-xyz = 123
3275
+ * ^^^
3135
3276
  */
3136
3277
  struct pm_node *value;
3137
3278
 
3138
3279
  /**
3139
3280
  * GlobalVariableWriteNode#operator_loc
3281
+ *
3282
+ * The location of the `=` operator.
3283
+ *
3284
+ * $foo = :bar
3285
+ * ^
3140
3286
  */
3141
3287
  pm_location_t operator_loc;
3142
3288
  } pm_global_variable_write_node_t;
@@ -3236,31 +3382,89 @@ typedef struct pm_if_node {
3236
3382
 
3237
3383
  /**
3238
3384
  * IfNode#if_keyword_loc
3385
+ *
3386
+ * The location of the `if` keyword if present.
3387
+ *
3388
+ * bar if foo
3389
+ * ^^
3390
+ *
3391
+ * The `if_keyword_loc` field will be `nil` when the `IfNode` represents a ternary expression.
3239
3392
  */
3240
3393
  pm_location_t if_keyword_loc;
3241
3394
 
3242
3395
  /**
3243
3396
  * IfNode#predicate
3397
+ *
3398
+ * The node for the condition the `IfNode` is testing.
3399
+ *
3400
+ * if foo
3401
+ * ^^^
3402
+ * bar
3403
+ * end
3404
+ *
3405
+ * bar if foo
3406
+ * ^^^
3407
+ *
3408
+ * foo ? bar : baz
3409
+ * ^^^
3244
3410
  */
3245
3411
  struct pm_node *predicate;
3246
3412
 
3247
3413
  /**
3248
3414
  * IfNode#then_keyword_loc
3415
+ *
3416
+ * The location of the `then` keyword (if present) or the `?` in a ternary expression, `nil` otherwise.
3417
+ *
3418
+ * if foo then bar end
3419
+ * ^^^^
3420
+ *
3421
+ * a ? b : c
3422
+ * ^
3249
3423
  */
3250
3424
  pm_location_t then_keyword_loc;
3251
3425
 
3252
3426
  /**
3253
3427
  * IfNode#statements
3428
+ *
3429
+ * Represents the body of statements that will be executed when the predicate is evaluated as truthy. Will be `nil` when no body is provided.
3430
+ *
3431
+ * if foo
3432
+ * bar
3433
+ * ^^^
3434
+ * baz
3435
+ * ^^^
3436
+ * end
3254
3437
  */
3255
3438
  struct pm_statements_node *statements;
3256
3439
 
3257
3440
  /**
3258
3441
  * IfNode#consequent
3442
+ *
3443
+ * Represents an `ElseNode` or an `IfNode` when there is an `else` or an `elsif` in the `if` statement.
3444
+ *
3445
+ * if foo
3446
+ * bar
3447
+ * elsif baz
3448
+ * ^^^^^^^^^
3449
+ * qux
3450
+ * ^^^
3451
+ * end
3452
+ * ^^^
3453
+ *
3454
+ * if foo then bar else baz end
3455
+ * ^^^^^^^^^^^^
3259
3456
  */
3260
3457
  struct pm_node *consequent;
3261
3458
 
3262
3459
  /**
3263
3460
  * IfNode#end_keyword_loc
3461
+ *
3462
+ * The location of the `end` keyword if present, `nil` otherwise.
3463
+ *
3464
+ * if foo
3465
+ * bar
3466
+ * end
3467
+ * ^^^
3264
3468
  */
3265
3469
  pm_location_t end_keyword_loc;
3266
3470
  } pm_if_node_t;
@@ -3737,8 +3941,7 @@ typedef struct pm_instance_variable_write_node {
3737
3941
  /**
3738
3942
  * InstanceVariableWriteNode#value
3739
3943
  *
3740
- * The value to assign to the instance variable. Can be any node that
3741
- * represents a non-void expression.
3944
+ * The value to write to the instance variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
3742
3945
  *
3743
3946
  * @foo = :bar
3744
3947
  * ^^^^
@@ -4242,26 +4445,62 @@ typedef struct pm_local_variable_write_node {
4242
4445
 
4243
4446
  /**
4244
4447
  * LocalVariableWriteNode#name
4448
+ *
4449
+ * The name of the local variable, which is an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers).
4450
+ *
4451
+ * foo = :bar # name `:foo`
4452
+ *
4453
+ * abc = 123 # name `:abc`
4245
4454
  */
4246
4455
  pm_constant_id_t name;
4247
4456
 
4248
4457
  /**
4249
4458
  * LocalVariableWriteNode#depth
4459
+ *
4460
+ * The number of semantic scopes we have to traverse to find the declaration of this variable.
4461
+ *
4462
+ * foo = 1 # depth 0
4463
+ *
4464
+ * tap { foo = 1 } # depth 1
4465
+ *
4466
+ * The specific rules for calculating the depth may differ from individual Ruby implementations, as they are not specified by the language. For more information, see [the Prism documentation](https://github.com/ruby/prism/blob/main/docs/local_variable_depth.md).
4250
4467
  */
4251
4468
  uint32_t depth;
4252
4469
 
4253
4470
  /**
4254
4471
  * LocalVariableWriteNode#name_loc
4472
+ *
4473
+ * The location of the variable name.
4474
+ *
4475
+ * foo = :bar
4476
+ * ^^^
4255
4477
  */
4256
4478
  pm_location_t name_loc;
4257
4479
 
4258
4480
  /**
4259
4481
  * LocalVariableWriteNode#value
4482
+ *
4483
+ * The value to write to the local variable. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
4484
+ *
4485
+ * foo = :bar
4486
+ * ^^^^
4487
+ *
4488
+ * abc = 1234
4489
+ * ^^^^
4490
+ *
4491
+ * Note that since the name of a local variable is known before the value is parsed, it is valid for a local variable to appear within the value of its own write.
4492
+ *
4493
+ * foo = foo
4260
4494
  */
4261
4495
  struct pm_node *value;
4262
4496
 
4263
4497
  /**
4264
4498
  * LocalVariableWriteNode#operator_loc
4499
+ *
4500
+ * The location of the `=` operator.
4501
+ *
4502
+ * x = :y
4503
+ * ^
4265
4504
  */
4266
4505
  pm_location_t operator_loc;
4267
4506
  } pm_local_variable_write_node_t;
@@ -5225,6 +5464,8 @@ typedef struct pm_retry_node {
5225
5464
  * ReturnNode
5226
5465
  *
5227
5466
  * Type: PM_RETURN_NODE
5467
+ * Flags:
5468
+ * PM_RETURN_NODE_FLAGS_REDUNDANT
5228
5469
  *
5229
5470
  * @extends pm_node_t
5230
5471
  */
@@ -5350,6 +5591,8 @@ typedef struct pm_source_file_node {
5350
5591
 
5351
5592
  /**
5352
5593
  * SourceFileNode#filepath
5594
+ *
5595
+ * Represents the file path being parsed. This corresponds directly to the `filepath` option given to the various `Prism::parse*` APIs.
5353
5596
  */
5354
5597
  pm_string_t filepath;
5355
5598
  } pm_source_file_node_t;
@@ -5562,31 +5805,66 @@ typedef struct pm_unless_node {
5562
5805
 
5563
5806
  /**
5564
5807
  * UnlessNode#keyword_loc
5808
+ *
5809
+ * The location of the `unless` keyword.
5810
+ *
5811
+ * unless cond then bar end
5812
+ * ^^^^^^
5813
+ *
5814
+ * bar unless cond
5815
+ * ^^^^^^
5565
5816
  */
5566
5817
  pm_location_t keyword_loc;
5567
5818
 
5568
5819
  /**
5569
5820
  * UnlessNode#predicate
5821
+ *
5822
+ * The condition to be evaluated for the unless expression. It can be any [non-void expression](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#non-void-expression).
5823
+ *
5824
+ * unless cond then bar end
5825
+ * ^^^^
5826
+ *
5827
+ * bar unless cond
5828
+ * ^^^^
5570
5829
  */
5571
5830
  struct pm_node *predicate;
5572
5831
 
5573
5832
  /**
5574
5833
  * UnlessNode#then_keyword_loc
5834
+ *
5835
+ * The location of the `then` keyword, if present.
5836
+ * unless cond then bar end ^^^^
5575
5837
  */
5576
5838
  pm_location_t then_keyword_loc;
5577
5839
 
5578
5840
  /**
5579
5841
  * UnlessNode#statements
5842
+ *
5843
+ * The body of statements that will executed if the unless condition is
5844
+ * falsey. Will be `nil` if no body is provided.
5845
+ *
5846
+ * unless cond then bar end
5847
+ * ^^^
5580
5848
  */
5581
5849
  struct pm_statements_node *statements;
5582
5850
 
5583
5851
  /**
5584
5852
  * UnlessNode#consequent
5853
+ *
5854
+ * The else clause of the unless expression, if present.
5855
+ *
5856
+ * unless cond then bar else baz end
5857
+ * ^^^^^^^^
5585
5858
  */
5586
5859
  struct pm_else_node *consequent;
5587
5860
 
5588
5861
  /**
5589
5862
  * UnlessNode#end_keyword_loc
5863
+ *
5864
+ * The location of the `end` keyword, if present.
5865
+ *
5866
+ * unless cond then bar end
5867
+ * ^^^
5590
5868
  */
5591
5869
  pm_location_t end_keyword_loc;
5592
5870
  } pm_unless_node_t;
@@ -5762,8 +6040,11 @@ typedef struct pm_yield_node {
5762
6040
  * Flags for arguments nodes.
5763
6041
  */
5764
6042
  typedef enum pm_arguments_node_flags {
6043
+ /** if arguments contain keywords */
6044
+ PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORDS = 1,
6045
+
5765
6046
  /** if arguments contain keyword splat */
5766
- PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT = 1,
6047
+ PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT = 2,
5767
6048
  } pm_arguments_node_flags_t;
5768
6049
 
5769
6050
  /**
@@ -5900,6 +6181,14 @@ typedef enum pm_regular_expression_flags {
5900
6181
  PM_REGULAR_EXPRESSION_FLAGS_FORCED_US_ASCII_ENCODING = 1024,
5901
6182
  } pm_regular_expression_flags_t;
5902
6183
 
6184
+ /**
6185
+ * Flags for return nodes.
6186
+ */
6187
+ typedef enum pm_return_node_flags {
6188
+ /** a return statement that is redundant because it is the last statement in a method */
6189
+ PM_RETURN_NODE_FLAGS_REDUNDANT = 1,
6190
+ } pm_return_node_flags_t;
6191
+
5903
6192
  /**
5904
6193
  * Flags for shareable constant nodes.
5905
6194
  */
@@ -152,17 +152,20 @@ typedef enum {
152
152
  PM_ERR_HASH_ROCKET,
153
153
  PM_ERR_HASH_TERM,
154
154
  PM_ERR_HASH_VALUE,
155
+ PM_ERR_HEREDOC_IDENTIFIER,
155
156
  PM_ERR_HEREDOC_TERM,
156
157
  PM_ERR_INCOMPLETE_QUESTION_MARK,
157
158
  PM_ERR_INCOMPLETE_VARIABLE_CLASS,
158
- PM_ERR_INCOMPLETE_VARIABLE_CLASS_3_3_0,
159
+ PM_ERR_INCOMPLETE_VARIABLE_CLASS_3_3,
159
160
  PM_ERR_INCOMPLETE_VARIABLE_INSTANCE,
160
- PM_ERR_INCOMPLETE_VARIABLE_INSTANCE_3_3_0,
161
+ PM_ERR_INCOMPLETE_VARIABLE_INSTANCE_3_3,
161
162
  PM_ERR_INSTANCE_VARIABLE_BARE,
162
163
  PM_ERR_INVALID_BLOCK_EXIT,
163
164
  PM_ERR_INVALID_CHARACTER,
164
165
  PM_ERR_INVALID_ENCODING_MAGIC_COMMENT,
165
166
  PM_ERR_INVALID_FLOAT_EXPONENT,
167
+ PM_ERR_INVALID_LOCAL_VARIABLE_READ,
168
+ PM_ERR_INVALID_LOCAL_VARIABLE_WRITE,
166
169
  PM_ERR_INVALID_MULTIBYTE_CHAR,
167
170
  PM_ERR_INVALID_MULTIBYTE_CHARACTER,
168
171
  PM_ERR_INVALID_MULTIBYTE_ESCAPE,
@@ -170,14 +173,16 @@ typedef enum {
170
173
  PM_ERR_INVALID_NUMBER_DECIMAL,
171
174
  PM_ERR_INVALID_NUMBER_HEXADECIMAL,
172
175
  PM_ERR_INVALID_NUMBER_OCTAL,
173
- PM_ERR_INVALID_NUMBER_UNDERSCORE,
176
+ PM_ERR_INVALID_NUMBER_UNDERSCORE_INNER,
177
+ PM_ERR_INVALID_NUMBER_UNDERSCORE_TRAILING,
174
178
  PM_ERR_INVALID_PERCENT,
175
179
  PM_ERR_INVALID_PRINTABLE_CHARACTER,
176
180
  PM_ERR_INVALID_RETRY_AFTER_ELSE,
177
181
  PM_ERR_INVALID_RETRY_AFTER_ENSURE,
178
182
  PM_ERR_INVALID_RETRY_WITHOUT_RESCUE,
183
+ PM_ERR_INVALID_SYMBOL,
179
184
  PM_ERR_INVALID_VARIABLE_GLOBAL,
180
- PM_ERR_INVALID_VARIABLE_GLOBAL_3_3_0,
185
+ PM_ERR_INVALID_VARIABLE_GLOBAL_3_3,
181
186
  PM_ERR_INVALID_YIELD,
182
187
  PM_ERR_IT_NOT_ALLOWED_NUMBERED,
183
188
  PM_ERR_IT_NOT_ALLOWED_ORDINARY,
@@ -221,6 +226,7 @@ typedef enum {
221
226
  PM_ERR_PARAMETER_STAR,
222
227
  PM_ERR_PARAMETER_UNEXPECTED_FWD,
223
228
  PM_ERR_PARAMETER_WILD_LOOSE_COMMA,
229
+ PM_ERR_PARAMETER_UNEXPECTED_NO_KW,
224
230
  PM_ERR_PATTERN_CAPTURE_DUPLICATE,
225
231
  PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET,
226
232
  PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA,
@@ -235,6 +241,7 @@ typedef enum {
235
241
  PM_ERR_PATTERN_HASH_KEY,
236
242
  PM_ERR_PATTERN_HASH_KEY_DUPLICATE,
237
243
  PM_ERR_PATTERN_HASH_KEY_LABEL,
244
+ PM_ERR_PATTERN_HASH_KEY_LOCALS,
238
245
  PM_ERR_PATTERN_IDENT_AFTER_HROCKET,
239
246
  PM_ERR_PATTERN_LABEL_AFTER_COMMA,
240
247
  PM_ERR_PATTERN_REST,
@@ -273,6 +280,9 @@ typedef enum {
273
280
  PM_ERR_UNARY_RECEIVER,
274
281
  PM_ERR_UNDEF_ARGUMENT,
275
282
  PM_ERR_UNEXPECTED_BLOCK_ARGUMENT,
283
+ PM_ERR_UNEXPECTED_INDEX_BLOCK,
284
+ PM_ERR_UNEXPECTED_INDEX_KEYWORDS,
285
+ PM_ERR_UNEXPECTED_SAFE_NAVIGATION,
276
286
  PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT,
277
287
  PM_ERR_UNEXPECTED_TOKEN_IGNORE,
278
288
  PM_ERR_UNTIL_TERM,
@@ -293,7 +303,7 @@ typedef enum {
293
303
  PM_WARN_COMPARISON_AFTER_COMPARISON,
294
304
  PM_WARN_DOT_DOT_DOT_EOL,
295
305
  PM_WARN_EQUAL_IN_CONDITIONAL,
296
- PM_WARN_EQUAL_IN_CONDITIONAL_3_3_0,
306
+ PM_WARN_EQUAL_IN_CONDITIONAL_3_3,
297
307
  PM_WARN_END_IN_METHOD,
298
308
  PM_WARN_DUPLICATED_HASH_KEY,
299
309
  PM_WARN_DUPLICATED_WHEN_CLAUSE,
@@ -49,8 +49,8 @@ typedef enum {
49
49
  /** The current version of prism. */
50
50
  PM_OPTIONS_VERSION_LATEST = 0,
51
51
 
52
- /** The vendored version of prism in CRuby 3.3.0. */
53
- PM_OPTIONS_VERSION_CRUBY_3_3_0 = 1
52
+ /** The vendored version of prism in CRuby 3.3.x. */
53
+ PM_OPTIONS_VERSION_CRUBY_3_3 = 1
54
54
  } pm_options_version_t;
55
55
 
56
56
  /**
@@ -10,6 +10,7 @@
10
10
  #include "prism/ast.h"
11
11
  #include "prism/encoding.h"
12
12
  #include "prism/options.h"
13
+ #include "prism/static_literals.h"
13
14
  #include "prism/util/pm_constant_pool.h"
14
15
  #include "prism/util/pm_list.h"
15
16
  #include "prism/util/pm_newline_list.h"
@@ -717,6 +718,15 @@ struct pm_parser {
717
718
  /** The current parsing context. */
718
719
  pm_context_node_t *current_context;
719
720
 
721
+ /**
722
+ * The hash keys for the hash that is currently being parsed. This is not
723
+ * usually necessary because it can pass it down the various call chains,
724
+ * but in the event that you're parsing a hash that is being directly
725
+ * pushed into another hash with **, we need to share the hash keys so that
726
+ * we can warn for the nested hash as well.
727
+ */
728
+ pm_static_literals_t *current_hash_keys;
729
+
720
730
  /**
721
731
  * The encoding functions for the current file is attached to the parser as
722
732
  * it's parsing so that it can change with a magic comment.