prism 0.27.0 → 0.28.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -1
  3. data/config.yml +39 -27
  4. data/docs/configuration.md +1 -0
  5. data/ext/prism/api_node.c +814 -807
  6. data/ext/prism/extension.c +5 -3
  7. data/ext/prism/extension.h +1 -1
  8. data/include/prism/ast.h +38 -16
  9. data/include/prism/diagnostic.h +12 -5
  10. data/include/prism/options.h +2 -2
  11. data/include/prism/parser.h +10 -0
  12. data/include/prism/static_literals.h +8 -6
  13. data/include/prism/version.h +2 -2
  14. data/lib/prism/dot_visitor.rb +22 -6
  15. data/lib/prism/dsl.rb +8 -8
  16. data/lib/prism/ffi.rb +3 -3
  17. data/lib/prism/inspect_visitor.rb +2156 -0
  18. data/lib/prism/lex_compat.rb +1 -1
  19. data/lib/prism/mutation_compiler.rb +2 -2
  20. data/lib/prism/node.rb +589 -1715
  21. data/lib/prism/node_ext.rb +34 -5
  22. data/lib/prism/parse_result.rb +78 -0
  23. data/lib/prism/pattern.rb +12 -6
  24. data/lib/prism/polyfill/byteindex.rb +13 -0
  25. data/lib/prism/polyfill/unpack1.rb +14 -0
  26. data/lib/prism/reflection.rb +13 -13
  27. data/lib/prism/serialize.rb +21 -14
  28. data/lib/prism/translation/parser/compiler.rb +2 -2
  29. data/lib/prism/translation/parser.rb +6 -6
  30. data/lib/prism/translation/ripper.rb +13 -9
  31. data/lib/prism/translation/ruby_parser.rb +4 -4
  32. data/lib/prism.rb +2 -1
  33. data/prism.gemspec +36 -38
  34. data/rbi/prism/compiler.rbi +3 -5
  35. data/rbi/prism/inspect_visitor.rbi +12 -0
  36. data/rbi/prism/node.rbi +354 -319
  37. data/rbi/prism/parse_result.rbi +23 -0
  38. data/rbi/prism/translation/ripper.rbi +1 -11
  39. data/sig/prism/dsl.rbs +3 -3
  40. data/sig/prism/inspect_visitor.rbs +22 -0
  41. data/sig/prism/node.rbs +64 -47
  42. data/sig/prism/parse_result.rbs +12 -0
  43. data/src/diagnostic.c +38 -24
  44. data/src/node.c +41 -16
  45. data/src/options.c +2 -2
  46. data/src/prettyprint.c +61 -18
  47. data/src/prism.c +607 -185
  48. data/src/serialize.c +5 -2
  49. data/src/static_literals.c +120 -34
  50. data/src/token_type.c +4 -4
  51. metadata +7 -9
  52. data/lib/prism/node_inspector.rb +0 -68
  53. data/lib/prism/polyfill/string.rb +0 -12
  54. data/rbi/prism/desugar_compiler.rbi +0 -5
  55. data/rbi/prism/mutation_compiler.rbi +0 -5
  56. data/rbi/prism/translation/parser/compiler.rbi +0 -13
  57. data/rbi/prism/translation/ripper/ripper_compiler.rbi +0 -5
  58. data/rbi/prism/translation/ruby_parser.rbi +0 -11
@@ -32,6 +32,7 @@ ID rb_option_id_frozen_string_literal;
32
32
  ID rb_option_id_line;
33
33
  ID rb_option_id_scopes;
34
34
  ID rb_option_id_version;
35
+ ID rb_prism_source_id_for;
35
36
 
36
37
  /******************************************************************************/
37
38
  /* IO of Ruby code */
@@ -599,8 +600,7 @@ parse_lex_input(pm_string_t *input, const pm_options_t *options, bool return_nod
599
600
 
600
601
  VALUE source_string = rb_str_new((const char *) pm_string_source(input), pm_string_length(input));
601
602
  VALUE offsets = rb_ary_new();
602
- VALUE source_argv[] = { source_string, LONG2NUM(parser.start_line), offsets };
603
- VALUE source = rb_class_new_instance(3, source_argv, rb_cPrismSource);
603
+ VALUE source = rb_funcall(rb_cPrismSource, rb_prism_source_id_for, 3, source_string, LONG2NUM(parser.start_line), offsets);
604
604
 
605
605
  parse_lex_data_t parse_lex_data = {
606
606
  .source = source,
@@ -1243,7 +1243,7 @@ static_inspect(int argc, VALUE *argv, VALUE self) {
1243
1243
  pm_node_t *node = ((pm_program_node_t *) program)->statements->body.nodes[0];
1244
1244
 
1245
1245
  pm_buffer_t buffer = { 0 };
1246
- pm_static_literal_inspect(&buffer, &parser, node);
1246
+ pm_static_literal_inspect(&buffer, &parser.newline_list, parser.start_line, parser.encoding->name, node);
1247
1247
 
1248
1248
  rb_encoding *encoding = rb_enc_find(parser.encoding->name);
1249
1249
  VALUE result = rb_enc_str_new(pm_buffer_value(&buffer), pm_buffer_length(&buffer), encoding);
@@ -1379,6 +1379,8 @@ Init_prism(void) {
1379
1379
  rb_option_id_scopes = rb_intern_const("scopes");
1380
1380
  rb_option_id_version = rb_intern_const("version");
1381
1381
 
1382
+ rb_prism_source_id_for = rb_intern("for");
1383
+
1382
1384
  /**
1383
1385
  * The version of the prism library.
1384
1386
  */
@@ -1,7 +1,7 @@
1
1
  #ifndef PRISM_EXT_NODE_H
2
2
  #define PRISM_EXT_NODE_H
3
3
 
4
- #define EXPECTED_PRISM_VERSION "0.27.0"
4
+ #define EXPECTED_PRISM_VERSION "0.28.0"
5
5
 
6
6
  #include <ruby.h>
7
7
  #include <ruby/encoding.h>
data/include/prism/ast.h CHANGED
@@ -1235,6 +1235,7 @@ typedef struct pm_and_node {
1235
1235
  *
1236
1236
  * Type: PM_ARGUMENTS_NODE
1237
1237
  * Flags:
1238
+ * PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORDS
1238
1239
  * PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT
1239
1240
  *
1240
1241
  * @extends pm_node_t
@@ -2427,21 +2428,11 @@ typedef struct pm_constant_path_node {
2427
2428
  struct pm_node *parent;
2428
2429
 
2429
2430
  /**
2430
- * ConstantPathNode#child
2431
+ * ConstantPathNode#name
2431
2432
  *
2432
- * The right-hand node of the path. Always a `ConstantReadNode` in a
2433
- * valid Ruby syntax tree.
2434
- *
2435
- * ::Foo
2436
- * ^^^
2437
- *
2438
- * self::Test
2439
- * ^^^^
2440
- *
2441
- * a.b::C
2442
- * ^
2433
+ * The name of the constant being accessed. This could be `nil` in the event of a syntax error.
2443
2434
  */
2444
- struct pm_node *child;
2435
+ pm_constant_id_t name;
2445
2436
 
2446
2437
  /**
2447
2438
  * ConstantPathNode#delimiter_loc
@@ -2455,6 +2446,19 @@ typedef struct pm_constant_path_node {
2455
2446
  * ^^
2456
2447
  */
2457
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;
2458
2462
  } pm_constant_path_node_t;
2459
2463
 
2460
2464
  /**
@@ -2533,14 +2537,19 @@ typedef struct pm_constant_path_target_node {
2533
2537
  struct pm_node *parent;
2534
2538
 
2535
2539
  /**
2536
- * ConstantPathTargetNode#child
2540
+ * ConstantPathTargetNode#name
2537
2541
  */
2538
- struct pm_node *child;
2542
+ pm_constant_id_t name;
2539
2543
 
2540
2544
  /**
2541
2545
  * ConstantPathTargetNode#delimiter_loc
2542
2546
  */
2543
2547
  pm_location_t delimiter_loc;
2548
+
2549
+ /**
2550
+ * ConstantPathTargetNode#name_loc
2551
+ */
2552
+ pm_location_t name_loc;
2544
2553
  } pm_constant_path_target_node_t;
2545
2554
 
2546
2555
  /**
@@ -5455,6 +5464,8 @@ typedef struct pm_retry_node {
5455
5464
  * ReturnNode
5456
5465
  *
5457
5466
  * Type: PM_RETURN_NODE
5467
+ * Flags:
5468
+ * PM_RETURN_NODE_FLAGS_REDUNDANT
5458
5469
  *
5459
5470
  * @extends pm_node_t
5460
5471
  */
@@ -6029,8 +6040,11 @@ typedef struct pm_yield_node {
6029
6040
  * Flags for arguments nodes.
6030
6041
  */
6031
6042
  typedef enum pm_arguments_node_flags {
6043
+ /** if arguments contain keywords */
6044
+ PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORDS = 1,
6045
+
6032
6046
  /** if arguments contain keyword splat */
6033
- PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT = 1,
6047
+ PM_ARGUMENTS_NODE_FLAGS_CONTAINS_KEYWORD_SPLAT = 2,
6034
6048
  } pm_arguments_node_flags_t;
6035
6049
 
6036
6050
  /**
@@ -6167,6 +6181,14 @@ typedef enum pm_regular_expression_flags {
6167
6181
  PM_REGULAR_EXPRESSION_FLAGS_FORCED_US_ASCII_ENCODING = 1024,
6168
6182
  } pm_regular_expression_flags_t;
6169
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
+
6170
6192
  /**
6171
6193
  * Flags for shareable constant nodes.
6172
6194
  */
@@ -152,12 +152,13 @@ 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,
@@ -172,14 +173,16 @@ typedef enum {
172
173
  PM_ERR_INVALID_NUMBER_DECIMAL,
173
174
  PM_ERR_INVALID_NUMBER_HEXADECIMAL,
174
175
  PM_ERR_INVALID_NUMBER_OCTAL,
175
- PM_ERR_INVALID_NUMBER_UNDERSCORE,
176
+ PM_ERR_INVALID_NUMBER_UNDERSCORE_INNER,
177
+ PM_ERR_INVALID_NUMBER_UNDERSCORE_TRAILING,
176
178
  PM_ERR_INVALID_PERCENT,
177
179
  PM_ERR_INVALID_PRINTABLE_CHARACTER,
178
180
  PM_ERR_INVALID_RETRY_AFTER_ELSE,
179
181
  PM_ERR_INVALID_RETRY_AFTER_ENSURE,
180
182
  PM_ERR_INVALID_RETRY_WITHOUT_RESCUE,
183
+ PM_ERR_INVALID_SYMBOL,
181
184
  PM_ERR_INVALID_VARIABLE_GLOBAL,
182
- PM_ERR_INVALID_VARIABLE_GLOBAL_3_3_0,
185
+ PM_ERR_INVALID_VARIABLE_GLOBAL_3_3,
183
186
  PM_ERR_INVALID_YIELD,
184
187
  PM_ERR_IT_NOT_ALLOWED_NUMBERED,
185
188
  PM_ERR_IT_NOT_ALLOWED_ORDINARY,
@@ -223,6 +226,7 @@ typedef enum {
223
226
  PM_ERR_PARAMETER_STAR,
224
227
  PM_ERR_PARAMETER_UNEXPECTED_FWD,
225
228
  PM_ERR_PARAMETER_WILD_LOOSE_COMMA,
229
+ PM_ERR_PARAMETER_UNEXPECTED_NO_KW,
226
230
  PM_ERR_PATTERN_CAPTURE_DUPLICATE,
227
231
  PM_ERR_PATTERN_EXPRESSION_AFTER_BRACKET,
228
232
  PM_ERR_PATTERN_EXPRESSION_AFTER_COMMA,
@@ -276,6 +280,9 @@ typedef enum {
276
280
  PM_ERR_UNARY_RECEIVER,
277
281
  PM_ERR_UNDEF_ARGUMENT,
278
282
  PM_ERR_UNEXPECTED_BLOCK_ARGUMENT,
283
+ PM_ERR_UNEXPECTED_INDEX_BLOCK,
284
+ PM_ERR_UNEXPECTED_INDEX_KEYWORDS,
285
+ PM_ERR_UNEXPECTED_SAFE_NAVIGATION,
279
286
  PM_ERR_UNEXPECTED_TOKEN_CLOSE_CONTEXT,
280
287
  PM_ERR_UNEXPECTED_TOKEN_IGNORE,
281
288
  PM_ERR_UNTIL_TERM,
@@ -296,7 +303,7 @@ typedef enum {
296
303
  PM_WARN_COMPARISON_AFTER_COMPARISON,
297
304
  PM_WARN_DOT_DOT_DOT_EOL,
298
305
  PM_WARN_EQUAL_IN_CONDITIONAL,
299
- PM_WARN_EQUAL_IN_CONDITIONAL_3_3_0,
306
+ PM_WARN_EQUAL_IN_CONDITIONAL_3_3,
300
307
  PM_WARN_END_IN_METHOD,
301
308
  PM_WARN_DUPLICATED_HASH_KEY,
302
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.
@@ -8,8 +8,7 @@
8
8
 
9
9
  #include "prism/defines.h"
10
10
  #include "prism/ast.h"
11
- #include "prism/node.h"
12
- #include "prism/parser.h"
11
+ #include "prism/util/pm_newline_list.h"
13
12
 
14
13
  #include <assert.h>
15
14
  #include <stdbool.h>
@@ -92,12 +91,13 @@ typedef struct {
92
91
  /**
93
92
  * Add a node to the set of static literals.
94
93
  *
95
- * @param parser The parser that created the node.
94
+ * @param newline_list The list of newline offsets to use to calculate lines.
95
+ * @param start_line The line number that the parser starts on.
96
96
  * @param literals The set of static literals to add the node to.
97
97
  * @param node The node to add to the set.
98
98
  * @return A pointer to the node that is being overwritten, if there is one.
99
99
  */
100
- pm_node_t * pm_static_literals_add(const pm_parser_t *parser, pm_static_literals_t *literals, pm_node_t *node);
100
+ pm_node_t * pm_static_literals_add(const pm_newline_list_t *newline_list, int32_t start_line, pm_static_literals_t *literals, pm_node_t *node);
101
101
 
102
102
  /**
103
103
  * Free the internal memory associated with the given static literals set.
@@ -110,9 +110,11 @@ void pm_static_literals_free(pm_static_literals_t *literals);
110
110
  * Create a string-based representation of the given static literal.
111
111
  *
112
112
  * @param buffer The buffer to write the string to.
113
- * @param parser The parser that created the node.
113
+ * @param newline_list The list of newline offsets to use to calculate lines.
114
+ * @param start_line The line number that the parser starts on.
115
+ * @param encoding_name The name of the encoding of the source being parsed.
114
116
  * @param node The node to create a string representation of.
115
117
  */
116
- PRISM_EXPORTED_FUNCTION void pm_static_literal_inspect(pm_buffer_t *buffer, const pm_parser_t *parser, const pm_node_t *node);
118
+ PRISM_EXPORTED_FUNCTION void pm_static_literal_inspect(pm_buffer_t *buffer, const pm_newline_list_t *newline_list, int32_t start_line, const char *encoding_name, const pm_node_t *node);
117
119
 
118
120
  #endif
@@ -14,7 +14,7 @@
14
14
  /**
15
15
  * The minor version of the Prism library as an int.
16
16
  */
17
- #define PRISM_VERSION_MINOR 27
17
+ #define PRISM_VERSION_MINOR 28
18
18
 
19
19
  /**
20
20
  * The patch version of the Prism library as an int.
@@ -24,6 +24,6 @@
24
24
  /**
25
25
  * The version of the Prism library as a constant string.
26
26
  */
27
- #define PRISM_VERSION "0.27.0"
27
+ #define PRISM_VERSION "0.28.0"
28
28
 
29
29
  #endif
@@ -1287,13 +1287,15 @@ module Prism
1287
1287
  digraph.edge("#{id}:parent -> #{node_id(parent)};")
1288
1288
  end
1289
1289
 
1290
- # child
1291
- table.field("child", port: true)
1292
- digraph.edge("#{id}:child -> #{node_id(node.child)};")
1290
+ # name
1291
+ table.field("name", node.name.inspect)
1293
1292
 
1294
1293
  # delimiter_loc
1295
1294
  table.field("delimiter_loc", location_inspect(node.delimiter_loc))
1296
1295
 
1296
+ # name_loc
1297
+ table.field("name_loc", location_inspect(node.name_loc))
1298
+
1297
1299
  digraph.nodes << <<~DOT
1298
1300
  #{id} [
1299
1301
  label=<#{table.to_dot.gsub(/\n/, "\n ")}>
@@ -1367,13 +1369,15 @@ module Prism
1367
1369
  digraph.edge("#{id}:parent -> #{node_id(parent)};")
1368
1370
  end
1369
1371
 
1370
- # child
1371
- table.field("child", port: true)
1372
- digraph.edge("#{id}:child -> #{node_id(node.child)};")
1372
+ # name
1373
+ table.field("name", node.name.inspect)
1373
1374
 
1374
1375
  # delimiter_loc
1375
1376
  table.field("delimiter_loc", location_inspect(node.delimiter_loc))
1376
1377
 
1378
+ # name_loc
1379
+ table.field("name_loc", location_inspect(node.name_loc))
1380
+
1377
1381
  digraph.nodes << <<~DOT
1378
1382
  #{id} [
1379
1383
  label=<#{table.to_dot.gsub(/\n/, "\n ")}>
@@ -3999,6 +4003,9 @@ module Prism
3999
4003
  table = Table.new("ReturnNode")
4000
4004
  id = node_id(node)
4001
4005
 
4006
+ # flags
4007
+ table.field("flags", return_node_flags_inspect(node))
4008
+
4002
4009
  # keyword_loc
4003
4010
  table.field("keyword_loc", location_inspect(node.keyword_loc))
4004
4011
 
@@ -4569,6 +4576,7 @@ module Prism
4569
4576
  # comma-separated list.
4570
4577
  def arguments_node_flags_inspect(node)
4571
4578
  flags = [] #: Array[String]
4579
+ flags << "contains_keywords" if node.contains_keywords?
4572
4580
  flags << "contains_keyword_splat" if node.contains_keyword_splat?
4573
4581
  flags.join(", ")
4574
4582
  end
@@ -4671,6 +4679,14 @@ module Prism
4671
4679
  flags.join(", ")
4672
4680
  end
4673
4681
 
4682
+ # Inspect a node that has return_node_flags flags to display the flags as a
4683
+ # comma-separated list.
4684
+ def return_node_flags_inspect(node)
4685
+ flags = [] #: Array[String]
4686
+ flags << "redundant" if node.redundant?
4687
+ flags.join(", ")
4688
+ end
4689
+
4674
4690
  # Inspect a node that has shareable_constant_node_flags flags to display the flags as a
4675
4691
  # comma-separated list.
4676
4692
  def shareable_constant_node_flags_inspect(node)
data/lib/prism/dsl.rb CHANGED
@@ -10,7 +10,7 @@ module Prism
10
10
  # The DSL module provides a set of methods that can be used to create prism
11
11
  # nodes in a more concise manner. For example, instead of writing:
12
12
  #
13
- # source = Prism::Source.new("[1]")
13
+ # source = Prism::Source.for("[1]")
14
14
  #
15
15
  # Prism::ArrayNode.new(
16
16
  # [
@@ -28,7 +28,7 @@ module Prism
28
28
  #
29
29
  # you could instead write:
30
30
  #
31
- # source = Prism::Source.new("[1]")
31
+ # source = Prism::Source.for("[1]")
32
32
  #
33
33
  # ArrayNode(
34
34
  # IntegerNode(Prism::IntegerBaseFlags::DECIMAL, 1, Location(source, 1, 1)), source),
@@ -228,8 +228,8 @@ module Prism
228
228
  end
229
229
 
230
230
  # Create a new ConstantPathNode node
231
- def ConstantPathNode(parent, child, delimiter_loc, source = nil, location = Location())
232
- ConstantPathNode.new(source, parent, child, delimiter_loc, location)
231
+ def ConstantPathNode(parent, name, delimiter_loc, name_loc, source = nil, location = Location())
232
+ ConstantPathNode.new(source, parent, name, delimiter_loc, name_loc, location)
233
233
  end
234
234
 
235
235
  # Create a new ConstantPathOperatorWriteNode node
@@ -243,8 +243,8 @@ module Prism
243
243
  end
244
244
 
245
245
  # Create a new ConstantPathTargetNode node
246
- def ConstantPathTargetNode(parent, child, delimiter_loc, source = nil, location = Location())
247
- ConstantPathTargetNode.new(source, parent, child, delimiter_loc, location)
246
+ def ConstantPathTargetNode(parent, name, delimiter_loc, name_loc, source = nil, location = Location())
247
+ ConstantPathTargetNode.new(source, parent, name, delimiter_loc, name_loc, location)
248
248
  end
249
249
 
250
250
  # Create a new ConstantPathWriteNode node
@@ -698,8 +698,8 @@ module Prism
698
698
  end
699
699
 
700
700
  # Create a new ReturnNode node
701
- def ReturnNode(keyword_loc, arguments, source = nil, location = Location())
702
- ReturnNode.new(source, keyword_loc, arguments, location)
701
+ def ReturnNode(flags, keyword_loc, arguments, source = nil, location = Location())
702
+ ReturnNode.new(source, flags, keyword_loc, arguments, location)
703
703
  end
704
704
 
705
705
  # Create a new SelfNode node
data/lib/prism/ffi.rb CHANGED
@@ -317,7 +317,7 @@ module Prism
317
317
  buffer.read
318
318
  end
319
319
 
320
- Serialize.load_tokens(Source.new(code), serialized)
320
+ Serialize.load_tokens(Source.for(code), serialized)
321
321
  end
322
322
 
323
323
  def parse_common(string, code, options) # :nodoc:
@@ -329,7 +329,7 @@ module Prism
329
329
  LibRubyParser::PrismBuffer.with do |buffer|
330
330
  LibRubyParser.pm_serialize_parse_comments(buffer.pointer, string.pointer, string.length, dump_options(options))
331
331
 
332
- source = Source.new(code)
332
+ source = Source.for(code)
333
333
  loader = Serialize::Loader.new(source, buffer.read)
334
334
 
335
335
  loader.load_header
@@ -343,7 +343,7 @@ module Prism
343
343
  LibRubyParser::PrismBuffer.with do |buffer|
344
344
  LibRubyParser.pm_serialize_parse_lex(buffer.pointer, string.pointer, string.length, dump_options(options))
345
345
 
346
- source = Source.new(code)
346
+ source = Source.for(code)
347
347
  loader = Serialize::Loader.new(source, buffer.read)
348
348
 
349
349
  tokens = loader.load_tokens