prism 0.27.0 → 0.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -1
  3. data/config.yml +68 -44
  4. data/docs/configuration.md +1 -0
  5. data/ext/prism/api_node.c +854 -847
  6. data/ext/prism/extconf.rb +27 -23
  7. data/ext/prism/extension.c +5 -3
  8. data/ext/prism/extension.h +1 -1
  9. data/include/prism/ast.h +70 -48
  10. data/include/prism/diagnostic.h +23 -6
  11. data/include/prism/options.h +2 -2
  12. data/include/prism/parser.h +10 -0
  13. data/include/prism/static_literals.h +8 -6
  14. data/include/prism/version.h +2 -2
  15. data/lib/prism/desugar_compiler.rb +4 -4
  16. data/lib/prism/dot_visitor.rb +54 -38
  17. data/lib/prism/dsl.rb +24 -24
  18. data/lib/prism/ffi.rb +4 -4
  19. data/lib/prism/inspect_visitor.rb +2156 -0
  20. data/lib/prism/lex_compat.rb +1 -1
  21. data/lib/prism/mutation_compiler.rb +2 -2
  22. data/lib/prism/node.rb +737 -1863
  23. data/lib/prism/node_ext.rb +176 -5
  24. data/lib/prism/parse_result/comments.rb +1 -1
  25. data/lib/prism/parse_result/newlines.rb +1 -1
  26. data/lib/prism/parse_result.rb +78 -0
  27. data/lib/prism/pattern.rb +12 -6
  28. data/lib/prism/polyfill/byteindex.rb +13 -0
  29. data/lib/prism/polyfill/unpack1.rb +14 -0
  30. data/lib/prism/reflection.rb +20 -20
  31. data/lib/prism/serialize.rb +32 -15
  32. data/lib/prism/translation/parser/compiler.rb +156 -26
  33. data/lib/prism/translation/parser.rb +7 -7
  34. data/lib/prism/translation/ripper.rb +29 -25
  35. data/lib/prism/translation/ruby_parser.rb +13 -13
  36. data/lib/prism.rb +2 -1
  37. data/prism.gemspec +37 -38
  38. data/rbi/prism/compiler.rbi +3 -5
  39. data/rbi/prism/inspect_visitor.rbi +12 -0
  40. data/rbi/prism/node.rbi +405 -370
  41. data/rbi/prism/node_ext.rbi +5 -0
  42. data/rbi/prism/parse_result.rbi +23 -0
  43. data/rbi/prism/translation/ripper.rbi +1 -11
  44. data/sig/prism/dsl.rbs +12 -12
  45. data/sig/prism/inspect_visitor.rbs +22 -0
  46. data/sig/prism/lex_compat.rbs +10 -0
  47. data/sig/prism/node.rbs +108 -91
  48. data/sig/prism/node_ext.rbs +4 -0
  49. data/sig/prism/parse_result.rbs +12 -0
  50. data/src/diagnostic.c +66 -33
  51. data/src/node.c +89 -64
  52. data/src/options.c +2 -2
  53. data/src/prettyprint.c +109 -66
  54. data/src/prism.c +862 -317
  55. data/src/serialize.c +21 -18
  56. data/src/static_literals.c +120 -34
  57. data/src/token_type.c +6 -6
  58. metadata +8 -9
  59. data/lib/prism/node_inspector.rb +0 -68
  60. data/lib/prism/polyfill/string.rb +0 -12
  61. data/rbi/prism/desugar_compiler.rbi +0 -5
  62. data/rbi/prism/mutation_compiler.rbi +0 -5
  63. data/rbi/prism/translation/parser/compiler.rbi +0 -13
  64. data/rbi/prism/translation/ripper/ripper_compiler.rbi +0 -5
  65. data/rbi/prism/translation/ruby_parser.rbi +0 -11
@@ -7,7 +7,7 @@ if you are looking to modify the template
7
7
  =end
8
8
 
9
9
  require "stringio"
10
- require_relative "polyfill/string"
10
+ require_relative "polyfill/unpack1"
11
11
 
12
12
  module Prism
13
13
  # A module responsible for deserializing parse results.
@@ -18,7 +18,7 @@ module Prism
18
18
 
19
19
  # The minor version of prism that we are expecting to find in the serialized
20
20
  # strings.
21
- MINOR_VERSION = 27
21
+ MINOR_VERSION = 29
22
22
 
23
23
  # The patch version of prism that we are expecting to find in the serialized
24
24
  # strings.
@@ -27,7 +27,7 @@ module Prism
27
27
  # Deserialize the AST represented by the given string into a parse result.
28
28
  def self.load(input, serialized)
29
29
  input = input.dup
30
- source = Source.new(input)
30
+ source = Source.for(input)
31
31
  loader = Loader.new(source, serialized)
32
32
  result = loader.load_result
33
33
 
@@ -133,13 +133,16 @@ module Prism
133
133
  :argument_bare_hash,
134
134
  :argument_block_forwarding,
135
135
  :argument_block_multi,
136
+ :argument_conflict_ampersand,
137
+ :argument_conflict_star,
138
+ :argument_conflict_star_star,
136
139
  :argument_formal_class,
137
140
  :argument_formal_constant,
138
141
  :argument_formal_global,
139
142
  :argument_formal_ivar,
140
143
  :argument_forwarding_unbound,
141
144
  :argument_in,
142
- :argument_no_forwarding_amp,
145
+ :argument_no_forwarding_ampersand,
143
146
  :argument_no_forwarding_ellipses,
144
147
  :argument_no_forwarding_star,
145
148
  :argument_no_forwarding_star_star,
@@ -221,6 +224,7 @@ module Prism
221
224
  :expect_expression_after_splat_hash,
222
225
  :expect_expression_after_star,
223
226
  :expect_ident_req_parameter,
227
+ :expect_in_delimiter,
224
228
  :expect_lparen_req_parameter,
225
229
  :expect_message,
226
230
  :expect_rbracket,
@@ -249,16 +253,18 @@ module Prism
249
253
  :hash_rocket,
250
254
  :hash_term,
251
255
  :hash_value,
256
+ :heredoc_identifier,
252
257
  :heredoc_term,
253
258
  :incomplete_question_mark,
254
259
  :incomplete_variable_class,
255
- :incomplete_variable_class_3_3_0,
260
+ :incomplete_variable_class_3_3,
256
261
  :incomplete_variable_instance,
257
- :incomplete_variable_instance_3_3_0,
262
+ :incomplete_variable_instance_3_3,
258
263
  :instance_variable_bare,
259
264
  :invalid_block_exit,
260
265
  :invalid_character,
261
266
  :invalid_encoding_magic_comment,
267
+ :invalid_escape_character,
262
268
  :invalid_float_exponent,
263
269
  :invalid_local_variable_read,
264
270
  :invalid_local_variable_write,
@@ -267,16 +273,19 @@ module Prism
267
273
  :invalid_multibyte_escape,
268
274
  :invalid_number_binary,
269
275
  :invalid_number_decimal,
276
+ :invalid_number_fraction,
270
277
  :invalid_number_hexadecimal,
271
278
  :invalid_number_octal,
272
- :invalid_number_underscore,
279
+ :invalid_number_underscore_inner,
280
+ :invalid_number_underscore_trailing,
273
281
  :invalid_percent,
274
282
  :invalid_printable_character,
275
283
  :invalid_retry_after_else,
276
284
  :invalid_retry_after_ensure,
277
285
  :invalid_retry_without_rescue,
286
+ :invalid_symbol,
278
287
  :invalid_variable_global,
279
- :invalid_variable_global_3_3_0,
288
+ :invalid_variable_global_3_3,
280
289
  :invalid_yield,
281
290
  :it_not_allowed_numbered,
282
291
  :it_not_allowed_ordinary,
@@ -310,6 +319,7 @@ module Prism
310
319
  :parameter_assoc_splat_multi,
311
320
  :parameter_block_multi,
312
321
  :parameter_circular,
322
+ :parameter_forwarding_after_rest,
313
323
  :parameter_method_name,
314
324
  :parameter_name_duplicated,
315
325
  :parameter_no_default,
@@ -320,6 +330,7 @@ module Prism
320
330
  :parameter_star,
321
331
  :parameter_unexpected_fwd,
322
332
  :parameter_wild_loose_comma,
333
+ :parameter_unexpected_no_kw,
323
334
  :pattern_capture_duplicate,
324
335
  :pattern_expression_after_bracket,
325
336
  :pattern_expression_after_comma,
@@ -331,8 +342,10 @@ module Prism
331
342
  :pattern_expression_after_pipe,
332
343
  :pattern_expression_after_range,
333
344
  :pattern_expression_after_rest,
345
+ :pattern_hash_implicit,
334
346
  :pattern_hash_key,
335
347
  :pattern_hash_key_duplicate,
348
+ :pattern_hash_key_interpolated,
336
349
  :pattern_hash_key_label,
337
350
  :pattern_hash_key_locals,
338
351
  :pattern_ident_after_hrocket,
@@ -373,6 +386,9 @@ module Prism
373
386
  :unary_receiver,
374
387
  :undef_argument,
375
388
  :unexpected_block_argument,
389
+ :unexpected_index_block,
390
+ :unexpected_index_keywords,
391
+ :unexpected_safe_navigation,
376
392
  :unexpected_token_close_context,
377
393
  :unexpected_token_ignore,
378
394
  :until_term,
@@ -391,7 +407,7 @@ module Prism
391
407
  :comparison_after_comparison,
392
408
  :dot_dot_dot_eol,
393
409
  :equal_in_conditional,
394
- :equal_in_conditional_3_3_0,
410
+ :equal_in_conditional_3_3,
395
411
  :end_in_method,
396
412
  :duplicated_hash_key,
397
413
  :duplicated_when_clause,
@@ -404,6 +420,7 @@ module Prism
404
420
  :keyword_eol,
405
421
  :literal_in_condition_default,
406
422
  :literal_in_condition_verbose,
423
+ :shareable_constant_value_line,
407
424
  :shebang_carriage_return,
408
425
  :unexpected_carriage_return,
409
426
  :unreachable_statement,
@@ -721,7 +738,7 @@ module Prism
721
738
  source, load_node, load_location, load_node, location)
722
739
  when 37 then
723
740
  ConstantPathNode.new(
724
- source, load_optional_node, load_node, load_location, location)
741
+ source, load_optional_node, load_optional_constant, load_location, load_location, location)
725
742
  when 38 then
726
743
  ConstantPathOperatorWriteNode.new(
727
744
  source, load_node, load_location, load_node, load_required_constant, location)
@@ -730,7 +747,7 @@ module Prism
730
747
  source, load_node, load_location, load_node, location)
731
748
  when 40 then
732
749
  ConstantPathTargetNode.new(
733
- source, load_optional_node, load_node, load_location, location)
750
+ source, load_optional_node, load_optional_constant, load_location, load_location, location)
734
751
  when 41 then
735
752
  ConstantPathWriteNode.new(
736
753
  source, load_node, load_location, load_node, location)
@@ -1004,7 +1021,7 @@ module Prism
1004
1021
  source, location)
1005
1022
  when 131 then
1006
1023
  ReturnNode.new(
1007
- source, load_location, load_optional_node, location)
1024
+ source, load_varuint, load_location, load_optional_node, location)
1008
1025
  when 132 then
1009
1026
  SelfNode.new(
1010
1027
  source, location)
@@ -1256,7 +1273,7 @@ module Prism
1256
1273
  -> {
1257
1274
  location = load_location
1258
1275
  ConstantPathNode.new(
1259
- source, load_optional_node, load_node, load_location, location)
1276
+ source, load_optional_node, load_optional_constant, load_location, load_location, location)
1260
1277
  },
1261
1278
  -> {
1262
1279
  location = load_location
@@ -1271,7 +1288,7 @@ module Prism
1271
1288
  -> {
1272
1289
  location = load_location
1273
1290
  ConstantPathTargetNode.new(
1274
- source, load_optional_node, load_node, load_location, location)
1291
+ source, load_optional_node, load_optional_constant, load_location, load_location, location)
1275
1292
  },
1276
1293
  -> {
1277
1294
  location = load_location
@@ -1727,7 +1744,7 @@ module Prism
1727
1744
  -> {
1728
1745
  location = load_location
1729
1746
  ReturnNode.new(
1730
- source, load_location, load_optional_node, location)
1747
+ source, load_varuint, load_location, load_optional_node, location)
1731
1748
  },
1732
1749
  -> {
1733
1750
  location = load_location
@@ -328,18 +328,48 @@ module Prism
328
328
  [],
329
329
  nil
330
330
  ),
331
- [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
331
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
332
332
  visit(node.value)
333
333
  )
334
334
  end
335
335
 
336
336
  # foo.bar &&= baz
337
337
  # ^^^^^^^^^^^^^^^
338
- alias visit_call_and_write_node visit_call_operator_write_node
338
+ def visit_call_and_write_node(node)
339
+ call_operator_loc = node.call_operator_loc
340
+
341
+ builder.op_assign(
342
+ builder.call_method(
343
+ visit(node.receiver),
344
+ call_operator_loc.nil? ? nil : [{ "." => :dot, "&." => :anddot, "::" => "::" }.fetch(call_operator_loc.slice), srange(call_operator_loc)],
345
+ node.message_loc ? [node.read_name, srange(node.message_loc)] : nil,
346
+ nil,
347
+ [],
348
+ nil
349
+ ),
350
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
351
+ visit(node.value)
352
+ )
353
+ end
339
354
 
340
355
  # foo.bar ||= baz
341
356
  # ^^^^^^^^^^^^^^^
342
- alias visit_call_or_write_node visit_call_operator_write_node
357
+ def visit_call_or_write_node(node)
358
+ call_operator_loc = node.call_operator_loc
359
+
360
+ builder.op_assign(
361
+ builder.call_method(
362
+ visit(node.receiver),
363
+ call_operator_loc.nil? ? nil : [{ "." => :dot, "&." => :anddot, "::" => "::" }.fetch(call_operator_loc.slice), srange(call_operator_loc)],
364
+ node.message_loc ? [node.read_name, srange(node.message_loc)] : nil,
365
+ nil,
366
+ [],
367
+ nil
368
+ ),
369
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
370
+ visit(node.value)
371
+ )
372
+ end
343
373
 
344
374
  # foo.bar, = 1
345
375
  # ^^^^^^^
@@ -419,18 +449,30 @@ module Prism
419
449
  def visit_class_variable_operator_write_node(node)
420
450
  builder.op_assign(
421
451
  builder.assignable(builder.cvar(token(node.name_loc))),
422
- [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
452
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
423
453
  visit(node.value)
424
454
  )
425
455
  end
426
456
 
427
457
  # @@foo &&= bar
428
458
  # ^^^^^^^^^^^^^
429
- alias visit_class_variable_and_write_node visit_class_variable_operator_write_node
459
+ def visit_class_variable_and_write_node(node)
460
+ builder.op_assign(
461
+ builder.assignable(builder.cvar(token(node.name_loc))),
462
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
463
+ visit(node.value)
464
+ )
465
+ end
430
466
 
431
467
  # @@foo ||= bar
432
468
  # ^^^^^^^^^^^^^
433
- alias visit_class_variable_or_write_node visit_class_variable_operator_write_node
469
+ def visit_class_variable_or_write_node(node)
470
+ builder.op_assign(
471
+ builder.assignable(builder.cvar(token(node.name_loc))),
472
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
473
+ visit(node.value)
474
+ )
475
+ end
434
476
 
435
477
  # @@foo, = bar
436
478
  # ^^^^^
@@ -458,18 +500,30 @@ module Prism
458
500
  def visit_constant_operator_write_node(node)
459
501
  builder.op_assign(
460
502
  builder.assignable(builder.const([node.name, srange(node.name_loc)])),
461
- [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
503
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
462
504
  visit(node.value)
463
505
  )
464
506
  end
465
507
 
466
508
  # Foo &&= bar
467
509
  # ^^^^^^^^^^^^
468
- alias visit_constant_and_write_node visit_constant_operator_write_node
510
+ def visit_constant_and_write_node(node)
511
+ builder.op_assign(
512
+ builder.assignable(builder.const([node.name, srange(node.name_loc)])),
513
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
514
+ visit(node.value)
515
+ )
516
+ end
469
517
 
470
518
  # Foo ||= bar
471
519
  # ^^^^^^^^^^^^
472
- alias visit_constant_or_write_node visit_constant_operator_write_node
520
+ def visit_constant_or_write_node(node)
521
+ builder.op_assign(
522
+ builder.assignable(builder.const([node.name, srange(node.name_loc)])),
523
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
524
+ visit(node.value)
525
+ )
526
+ end
473
527
 
474
528
  # Foo, = bar
475
529
  # ^^^
@@ -483,13 +537,13 @@ module Prism
483
537
  if node.parent.nil?
484
538
  builder.const_global(
485
539
  token(node.delimiter_loc),
486
- [node.child.name, srange(node.child.location)]
540
+ [node.name, srange(node.name_loc)]
487
541
  )
488
542
  else
489
543
  builder.const_fetch(
490
544
  visit(node.parent),
491
545
  token(node.delimiter_loc),
492
- [node.child.name, srange(node.child.location)]
546
+ [node.name, srange(node.name_loc)]
493
547
  )
494
548
  end
495
549
  end
@@ -512,18 +566,30 @@ module Prism
512
566
  def visit_constant_path_operator_write_node(node)
513
567
  builder.op_assign(
514
568
  builder.assignable(visit(node.target)),
515
- [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
569
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
516
570
  visit(node.value)
517
571
  )
518
572
  end
519
573
 
520
574
  # Foo::Bar &&= baz
521
575
  # ^^^^^^^^^^^^^^^^
522
- alias visit_constant_path_and_write_node visit_constant_path_operator_write_node
576
+ def visit_constant_path_and_write_node(node)
577
+ builder.op_assign(
578
+ builder.assignable(visit(node.target)),
579
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
580
+ visit(node.value)
581
+ )
582
+ end
523
583
 
524
584
  # Foo::Bar ||= baz
525
585
  # ^^^^^^^^^^^^^^^^
526
- alias visit_constant_path_or_write_node visit_constant_path_operator_write_node
586
+ def visit_constant_path_or_write_node(node)
587
+ builder.op_assign(
588
+ builder.assignable(visit(node.target)),
589
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
590
+ visit(node.value)
591
+ )
592
+ end
527
593
 
528
594
  # Foo::Bar, = baz
529
595
  # ^^^^^^^^
@@ -711,18 +777,30 @@ module Prism
711
777
  def visit_global_variable_operator_write_node(node)
712
778
  builder.op_assign(
713
779
  builder.assignable(builder.gvar(token(node.name_loc))),
714
- [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
780
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
715
781
  visit(node.value)
716
782
  )
717
783
  end
718
784
 
719
785
  # $foo &&= bar
720
786
  # ^^^^^^^^^^^^
721
- alias visit_global_variable_and_write_node visit_global_variable_operator_write_node
787
+ def visit_global_variable_and_write_node(node)
788
+ builder.op_assign(
789
+ builder.assignable(builder.gvar(token(node.name_loc))),
790
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
791
+ visit(node.value)
792
+ )
793
+ end
722
794
 
723
795
  # $foo ||= bar
724
796
  # ^^^^^^^^^^^^
725
- alias visit_global_variable_or_write_node visit_global_variable_operator_write_node
797
+ def visit_global_variable_or_write_node(node)
798
+ builder.op_assign(
799
+ builder.assignable(builder.gvar(token(node.name_loc))),
800
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
801
+ visit(node.value)
802
+ )
803
+ end
726
804
 
727
805
  # $foo, = bar
728
806
  # ^^^^
@@ -857,18 +935,46 @@ module Prism
857
935
  visit_all(arguments),
858
936
  token(node.closing_loc)
859
937
  ),
860
- [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
938
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
861
939
  visit(node.value)
862
940
  )
863
941
  end
864
942
 
865
943
  # foo[bar] &&= baz
866
944
  # ^^^^^^^^^^^^^^^^
867
- alias visit_index_and_write_node visit_index_operator_write_node
945
+ def visit_index_and_write_node(node)
946
+ arguments = node.arguments&.arguments || []
947
+ arguments << node.block if node.block
948
+
949
+ builder.op_assign(
950
+ builder.index(
951
+ visit(node.receiver),
952
+ token(node.opening_loc),
953
+ visit_all(arguments),
954
+ token(node.closing_loc)
955
+ ),
956
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
957
+ visit(node.value)
958
+ )
959
+ end
868
960
 
869
961
  # foo[bar] ||= baz
870
962
  # ^^^^^^^^^^^^^^^^
871
- alias visit_index_or_write_node visit_index_operator_write_node
963
+ def visit_index_or_write_node(node)
964
+ arguments = node.arguments&.arguments || []
965
+ arguments << node.block if node.block
966
+
967
+ builder.op_assign(
968
+ builder.index(
969
+ visit(node.receiver),
970
+ token(node.opening_loc),
971
+ visit_all(arguments),
972
+ token(node.closing_loc)
973
+ ),
974
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
975
+ visit(node.value)
976
+ )
977
+ end
872
978
 
873
979
  # foo[bar], = 1
874
980
  # ^^^^^^^^
@@ -902,18 +1008,30 @@ module Prism
902
1008
  def visit_instance_variable_operator_write_node(node)
903
1009
  builder.op_assign(
904
1010
  builder.assignable(builder.ivar(token(node.name_loc))),
905
- [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
1011
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
906
1012
  visit(node.value)
907
1013
  )
908
1014
  end
909
1015
 
910
1016
  # @foo &&= bar
911
1017
  # ^^^^^^^^^^^^
912
- alias visit_instance_variable_and_write_node visit_instance_variable_operator_write_node
1018
+ def visit_instance_variable_and_write_node(node)
1019
+ builder.op_assign(
1020
+ builder.assignable(builder.ivar(token(node.name_loc))),
1021
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
1022
+ visit(node.value)
1023
+ )
1024
+ end
913
1025
 
914
1026
  # @foo ||= bar
915
1027
  # ^^^^^^^^^^^^
916
- alias visit_instance_variable_or_write_node visit_instance_variable_operator_write_node
1028
+ def visit_instance_variable_or_write_node(node)
1029
+ builder.op_assign(
1030
+ builder.assignable(builder.ivar(token(node.name_loc))),
1031
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
1032
+ visit(node.value)
1033
+ )
1034
+ end
917
1035
 
918
1036
  # @foo, = bar
919
1037
  # ^^^^
@@ -1108,18 +1226,30 @@ module Prism
1108
1226
  def visit_local_variable_operator_write_node(node)
1109
1227
  builder.op_assign(
1110
1228
  builder.assignable(builder.ident(token(node.name_loc))),
1111
- [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
1229
+ [node.binary_operator_loc.slice.chomp("="), srange(node.binary_operator_loc)],
1112
1230
  visit(node.value)
1113
1231
  )
1114
1232
  end
1115
1233
 
1116
1234
  # foo &&= bar
1117
1235
  # ^^^^^^^^^^^
1118
- alias visit_local_variable_and_write_node visit_local_variable_operator_write_node
1236
+ def visit_local_variable_and_write_node(node)
1237
+ builder.op_assign(
1238
+ builder.assignable(builder.ident(token(node.name_loc))),
1239
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
1240
+ visit(node.value)
1241
+ )
1242
+ end
1119
1243
 
1120
1244
  # foo ||= bar
1121
1245
  # ^^^^^^^^^^^
1122
- alias visit_local_variable_or_write_node visit_local_variable_operator_write_node
1246
+ def visit_local_variable_or_write_node(node)
1247
+ builder.op_assign(
1248
+ builder.assignable(builder.ident(token(node.name_loc))),
1249
+ [node.operator_loc.slice.chomp("="), srange(node.operator_loc)],
1250
+ visit(node.value)
1251
+ )
1252
+ end
1123
1253
 
1124
1254
  # foo, = bar
1125
1255
  # ^^^
@@ -46,7 +46,7 @@ module Prism
46
46
  source = source_buffer.source
47
47
 
48
48
  offset_cache = build_offset_cache(source)
49
- result = unwrap(Prism.parse(source, filepath: source_buffer.name, version: convert_for_prism(version)), offset_cache)
49
+ result = unwrap(Prism.parse(source, filepath: source_buffer.name, version: convert_for_prism(version), scopes: [[]]), offset_cache)
50
50
 
51
51
  build_ast(result.value, offset_cache)
52
52
  ensure
@@ -59,7 +59,7 @@ module Prism
59
59
  source = source_buffer.source
60
60
 
61
61
  offset_cache = build_offset_cache(source)
62
- result = unwrap(Prism.parse(source, filepath: source_buffer.name, version: convert_for_prism(version)), offset_cache)
62
+ result = unwrap(Prism.parse(source, filepath: source_buffer.name, version: convert_for_prism(version), scopes: [[]]), offset_cache)
63
63
 
64
64
  [
65
65
  build_ast(result.value, offset_cache),
@@ -78,7 +78,7 @@ module Prism
78
78
  offset_cache = build_offset_cache(source)
79
79
  result =
80
80
  begin
81
- unwrap(Prism.parse_lex(source, filepath: source_buffer.name, version: convert_for_prism(version)), offset_cache)
81
+ unwrap(Prism.parse_lex(source, filepath: source_buffer.name, version: convert_for_prism(version), scopes: [[]]), offset_cache)
82
82
  rescue ::Parser::SyntaxError
83
83
  raise if !recover
84
84
  end
@@ -149,17 +149,17 @@ module Prism
149
149
  Diagnostic.new(:error, :endless_setter, {}, diagnostic_location, [])
150
150
  when :embdoc_term
151
151
  Diagnostic.new(:error, :embedded_document, {}, diagnostic_location, [])
152
- when :incomplete_variable_class, :incomplete_variable_class_3_3_0
152
+ when :incomplete_variable_class, :incomplete_variable_class_3_3
153
153
  location = location.copy(length: location.length + 1)
154
154
  diagnostic_location = build_range(location, offset_cache)
155
155
 
156
156
  Diagnostic.new(:error, :cvar_name, { name: location.slice }, diagnostic_location, [])
157
- when :incomplete_variable_instance, :incomplete_variable_instance_3_3_0
157
+ when :incomplete_variable_instance, :incomplete_variable_instance_3_3
158
158
  location = location.copy(length: location.length + 1)
159
159
  diagnostic_location = build_range(location, offset_cache)
160
160
 
161
161
  Diagnostic.new(:error, :ivar_name, { name: location.slice }, diagnostic_location, [])
162
- when :invalid_variable_global, :invalid_variable_global_3_3_0
162
+ when :invalid_variable_global, :invalid_variable_global_3_3
163
163
  Diagnostic.new(:error, :gvar_name, { name: location.slice }, diagnostic_location, [])
164
164
  when :module_in_method
165
165
  Diagnostic.new(:error, :module_in_def, {}, diagnostic_location, [])
@@ -284,7 +284,7 @@ module Prism
284
284
  def convert_for_prism(version)
285
285
  case version
286
286
  when 33
287
- "3.3.0"
287
+ "3.3.1"
288
288
  when 34
289
289
  "3.4.0"
290
290
  else