prism 1.5.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +74 -1
  3. data/Makefile +12 -5
  4. data/README.md +2 -1
  5. data/config.yml +34 -8
  6. data/docs/build_system.md +2 -2
  7. data/docs/cruby_compilation.md +1 -1
  8. data/docs/design.md +2 -2
  9. data/docs/parser_translation.md +1 -1
  10. data/docs/releasing.md +4 -25
  11. data/docs/ripper_translation.md +8 -17
  12. data/docs/ruby_api.md +1 -0
  13. data/ext/prism/api_node.c +7 -3
  14. data/ext/prism/extconf.rb +1 -1
  15. data/ext/prism/extension.c +10 -2
  16. data/ext/prism/extension.h +1 -1
  17. data/include/prism/ast.h +89 -25
  18. data/include/prism/diagnostic.h +3 -0
  19. data/include/prism/options.h +8 -2
  20. data/include/prism/parser.h +3 -0
  21. data/include/prism/version.h +3 -3
  22. data/include/prism.h +1 -1
  23. data/lib/prism/compiler.rb +152 -152
  24. data/lib/prism/dot_visitor.rb +5 -0
  25. data/lib/prism/dsl.rb +2 -2
  26. data/lib/prism/ffi.rb +11 -3
  27. data/lib/prism/inspect_visitor.rb +1 -0
  28. data/lib/prism/lex_compat.rb +133 -150
  29. data/lib/prism/node.rb +1184 -34
  30. data/lib/prism/parse_result.rb +11 -15
  31. data/lib/prism/polyfill/scan_byte.rb +1 -1
  32. data/lib/prism/polyfill/warn.rb +16 -22
  33. data/lib/prism/reflection.rb +1 -1
  34. data/lib/prism/serialize.rb +8 -5
  35. data/lib/prism/translation/parser/compiler.rb +16 -16
  36. data/lib/prism/translation/parser.rb +12 -3
  37. data/lib/prism/translation/parser_current.rb +5 -3
  38. data/lib/prism/translation/parser_versions.rb +36 -0
  39. data/lib/prism/translation/ripper/filter.rb +53 -0
  40. data/lib/prism/translation/ripper/lexer.rb +135 -0
  41. data/lib/prism/translation/ripper.rb +86 -40
  42. data/lib/prism/translation/ruby_parser.rb +55 -20
  43. data/lib/prism/translation.rb +5 -3
  44. data/lib/prism/visitor.rb +152 -152
  45. data/lib/prism.rb +21 -14
  46. data/prism.gemspec +5 -7
  47. data/rbi/prism/dsl.rbi +3 -3
  48. data/rbi/prism/node.rbi +24 -8
  49. data/rbi/prism/translation/parser_versions.rbi +23 -0
  50. data/rbi/prism.rbi +0 -3
  51. data/sig/prism/dsl.rbs +2 -2
  52. data/sig/prism/node.rbs +22 -8
  53. data/sig/prism/parse_result.rbs +1 -0
  54. data/sig/prism.rbs +58 -40
  55. data/src/diagnostic.c +7 -1
  56. data/src/encoding.c +172 -67
  57. data/src/node.c +9 -0
  58. data/src/options.c +17 -7
  59. data/src/prettyprint.c +16 -0
  60. data/src/prism.c +1335 -1958
  61. data/src/serialize.c +7 -1
  62. data/src/token_type.c +2 -2
  63. data/src/util/pm_constant_pool.c +1 -1
  64. data/src/util/pm_string.c +6 -8
  65. metadata +7 -9
  66. data/lib/prism/translation/parser33.rb +0 -13
  67. data/lib/prism/translation/parser34.rb +0 -13
  68. data/lib/prism/translation/parser35.rb +0 -13
  69. data/rbi/prism/translation/parser33.rbi +0 -6
  70. data/rbi/prism/translation/parser34.rbi +0 -6
  71. data/rbi/prism/translation/parser35.rbi +0 -6
data/lib/prism.rb CHANGED
@@ -20,7 +20,6 @@ module Prism
20
20
  autoload :DSL, "prism/dsl"
21
21
  autoload :InspectVisitor, "prism/inspect_visitor"
22
22
  autoload :LexCompat, "prism/lex_compat"
23
- autoload :LexRipper, "prism/lex_compat"
24
23
  autoload :MutationCompiler, "prism/mutation_compiler"
25
24
  autoload :Pack, "prism/pack"
26
25
  autoload :Pattern, "prism/pattern"
@@ -35,30 +34,38 @@ module Prism
35
34
  # private here.
36
35
 
37
36
  private_constant :LexCompat
38
- private_constant :LexRipper
37
+
38
+ # Raised when requested to parse as the currently running Ruby version but Prism has no support for it.
39
+ class CurrentVersionError < ArgumentError
40
+ # Initialize a new exception for the given ruby version string.
41
+ def initialize(version)
42
+ message = +"invalid version: Requested to parse as `version: 'current'`; "
43
+ segments =
44
+ if version.match?(/\A\d+\.\d+.\d+\z/)
45
+ version.split(".").map(&:to_i)
46
+ end
47
+
48
+ if segments && ((segments[0] < 3) || (segments[0] == 3 && segments[1] < 3))
49
+ message << " #{version} is below the minimum supported syntax."
50
+ else
51
+ message << " #{version} is unknown. Please update the `prism` gem."
52
+ end
53
+
54
+ super(message)
55
+ end
56
+ end
39
57
 
40
58
  # :call-seq:
41
59
  # Prism::lex_compat(source, **options) -> LexCompat::Result
42
60
  #
43
61
  # Returns a parse result whose value is an array of tokens that closely
44
- # resembles the return value of Ripper::lex. The main difference is that the
45
- # `:on_sp` token is not emitted.
62
+ # resembles the return value of Ripper::lex.
46
63
  #
47
64
  # For supported options, see Prism::parse.
48
65
  def self.lex_compat(source, **options)
49
66
  LexCompat.new(source, **options).result # steep:ignore
50
67
  end
51
68
 
52
- # :call-seq:
53
- # Prism::lex_ripper(source) -> Array
54
- #
55
- # This lexes with the Ripper lex. It drops any space events but otherwise
56
- # returns the same tokens. Raises SyntaxError if the syntax in source is
57
- # invalid.
58
- def self.lex_ripper(source)
59
- LexRipper.new(source).result # steep:ignore
60
- end
61
-
62
69
  # :call-seq:
63
70
  # Prism::load(source, serialized, freeze) -> ParseResult
64
71
  #
data/prism.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "prism"
5
- spec.version = "1.5.1"
5
+ spec.version = "1.9.0"
6
6
  spec.authors = ["Shopify"]
7
7
  spec.email = ["ruby@shopify.com"]
8
8
 
@@ -98,13 +98,13 @@ Gem::Specification.new do |spec|
98
98
  "lib/prism/translation.rb",
99
99
  "lib/prism/translation/parser.rb",
100
100
  "lib/prism/translation/parser_current.rb",
101
- "lib/prism/translation/parser33.rb",
102
- "lib/prism/translation/parser34.rb",
103
- "lib/prism/translation/parser35.rb",
101
+ "lib/prism/translation/parser_versions.rb",
104
102
  "lib/prism/translation/parser/builder.rb",
105
103
  "lib/prism/translation/parser/compiler.rb",
106
104
  "lib/prism/translation/parser/lexer.rb",
107
105
  "lib/prism/translation/ripper.rb",
106
+ "lib/prism/translation/ripper/filter.rb",
107
+ "lib/prism/translation/ripper/lexer.rb",
108
108
  "lib/prism/translation/ripper/sexp.rb",
109
109
  "lib/prism/translation/ripper/shim.rb",
110
110
  "lib/prism/translation/ruby_parser.rb",
@@ -120,9 +120,7 @@ Gem::Specification.new do |spec|
120
120
  "rbi/prism/reflection.rbi",
121
121
  "rbi/prism/string_query.rbi",
122
122
  "rbi/prism/translation/parser.rbi",
123
- "rbi/prism/translation/parser33.rbi",
124
- "rbi/prism/translation/parser34.rbi",
125
- "rbi/prism/translation/parser35.rbi",
123
+ "rbi/prism/translation/parser_versions.rbi",
126
124
  "rbi/prism/translation/ripper.rbi",
127
125
  "rbi/prism/visitor.rbi",
128
126
  "sig/prism.rbs",
data/rbi/prism/dsl.rbi CHANGED
@@ -67,8 +67,8 @@ module Prism::DSL
67
67
  sig { params(source: Prism::Source, node_id: Integer, location: Prism::Location, flags: Integer, receiver: T.nilable(Prism::Node), call_operator_loc: T.nilable(Prism::Location), message_loc: T.nilable(Prism::Location), read_name: Symbol, write_name: Symbol, operator_loc: Prism::Location, value: Prism::Node).returns(Prism::CallAndWriteNode) }
68
68
  def call_and_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, receiver: nil, call_operator_loc: nil, message_loc: nil, read_name: :"", write_name: :"", operator_loc: location, value: default_node(source, location)); end
69
69
 
70
- sig { params(source: Prism::Source, node_id: Integer, location: Prism::Location, flags: Integer, receiver: T.nilable(Prism::Node), call_operator_loc: T.nilable(Prism::Location), name: Symbol, message_loc: T.nilable(Prism::Location), opening_loc: T.nilable(Prism::Location), arguments: T.nilable(Prism::ArgumentsNode), closing_loc: T.nilable(Prism::Location), block: T.nilable(T.any(Prism::BlockNode, Prism::BlockArgumentNode))).returns(Prism::CallNode) }
71
- def call_node(source: default_source, node_id: 0, location: default_location, flags: 0, receiver: nil, call_operator_loc: nil, name: :"", message_loc: nil, opening_loc: nil, arguments: nil, closing_loc: nil, block: nil); end
70
+ sig { params(source: Prism::Source, node_id: Integer, location: Prism::Location, flags: Integer, receiver: T.nilable(Prism::Node), call_operator_loc: T.nilable(Prism::Location), name: Symbol, message_loc: T.nilable(Prism::Location), opening_loc: T.nilable(Prism::Location), arguments: T.nilable(Prism::ArgumentsNode), closing_loc: T.nilable(Prism::Location), equal_loc: T.nilable(Prism::Location), block: T.nilable(T.any(Prism::BlockNode, Prism::BlockArgumentNode))).returns(Prism::CallNode) }
71
+ def call_node(source: default_source, node_id: 0, location: default_location, flags: 0, receiver: nil, call_operator_loc: nil, name: :"", message_loc: nil, opening_loc: nil, arguments: nil, closing_loc: nil, equal_loc: nil, block: nil); end
72
72
 
73
73
  sig { params(source: Prism::Source, node_id: Integer, location: Prism::Location, flags: Integer, receiver: T.nilable(Prism::Node), call_operator_loc: T.nilable(Prism::Location), message_loc: T.nilable(Prism::Location), read_name: Symbol, write_name: Symbol, binary_operator: Symbol, binary_operator_loc: Prism::Location, value: Prism::Node).returns(Prism::CallOperatorWriteNode) }
74
74
  def call_operator_write_node(source: default_source, node_id: 0, location: default_location, flags: 0, receiver: nil, call_operator_loc: nil, message_loc: nil, read_name: :"", write_name: :"", binary_operator: :"", binary_operator_loc: location, value: default_node(source, location)); end
@@ -265,7 +265,7 @@ module Prism::DSL
265
265
  sig { params(source: Prism::Source, node_id: Integer, location: Prism::Location, flags: Integer, opening_loc: Prism::Location, parts: T::Array[T.any(Prism::StringNode, Prism::EmbeddedStatementsNode, Prism::EmbeddedVariableNode)], closing_loc: Prism::Location).returns(Prism::InterpolatedRegularExpressionNode) }
266
266
  def interpolated_regular_expression_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: location, parts: [], closing_loc: location); end
267
267
 
268
- sig { params(source: Prism::Source, node_id: Integer, location: Prism::Location, flags: Integer, opening_loc: T.nilable(Prism::Location), parts: T::Array[T.any(Prism::StringNode, Prism::EmbeddedStatementsNode, Prism::EmbeddedVariableNode, Prism::InterpolatedStringNode, Prism::XStringNode)], closing_loc: T.nilable(Prism::Location)).returns(Prism::InterpolatedStringNode) }
268
+ sig { params(source: Prism::Source, node_id: Integer, location: Prism::Location, flags: Integer, opening_loc: T.nilable(Prism::Location), parts: T::Array[T.any(Prism::StringNode, Prism::EmbeddedStatementsNode, Prism::EmbeddedVariableNode, Prism::InterpolatedStringNode, Prism::XStringNode, Prism::InterpolatedXStringNode, Prism::SymbolNode, Prism::InterpolatedSymbolNode)], closing_loc: T.nilable(Prism::Location)).returns(Prism::InterpolatedStringNode) }
269
269
  def interpolated_string_node(source: default_source, node_id: 0, location: default_location, flags: 0, opening_loc: nil, parts: [], closing_loc: nil); end
270
270
 
271
271
  sig { params(source: Prism::Source, node_id: Integer, location: Prism::Location, flags: Integer, opening_loc: T.nilable(Prism::Location), parts: T::Array[T.any(Prism::StringNode, Prism::EmbeddedStatementsNode, Prism::EmbeddedVariableNode)], closing_loc: T.nilable(Prism::Location)).returns(Prism::InterpolatedSymbolNode) }
data/rbi/prism/node.rbi CHANGED
@@ -57,6 +57,9 @@ class Prism::Node
57
57
  sig { params(block: T.proc.params(node: Prism::Node).returns(T::Boolean)).returns(T.nilable(Prism::Node)) }
58
58
  def breadth_first_search(&block); end
59
59
 
60
+ sig { params(block: T.proc.params(node: Prism::Node).returns(T::Boolean)).returns(T::Array[Prism::Node]) }
61
+ def breadth_first_search_all(&block); end
62
+
60
63
  sig { abstract.params(visitor: Prism::Visitor).returns(T.untyped) }
61
64
  def accept(visitor); end
62
65
 
@@ -1132,11 +1135,14 @@ class Prism::CallNode < Prism::Node
1132
1135
  sig { returns(T.nilable(Prism::Location)) }
1133
1136
  def closing_loc; end
1134
1137
 
1138
+ sig { returns(T.nilable(Prism::Location)) }
1139
+ def equal_loc; end
1140
+
1135
1141
  sig { returns(T.nilable(T.any(Prism::BlockNode, Prism::BlockArgumentNode))) }
1136
1142
  def block; end
1137
1143
 
1138
- sig { params(source: Prism::Source, node_id: Integer, location: Prism::Location, flags: Integer, receiver: T.nilable(Prism::Node), call_operator_loc: T.nilable(Prism::Location), name: Symbol, message_loc: T.nilable(Prism::Location), opening_loc: T.nilable(Prism::Location), arguments: T.nilable(Prism::ArgumentsNode), closing_loc: T.nilable(Prism::Location), block: T.nilable(T.any(Prism::BlockNode, Prism::BlockArgumentNode))).void }
1139
- def initialize(source, node_id, location, flags, receiver, call_operator_loc, name, message_loc, opening_loc, arguments, closing_loc, block); end
1144
+ sig { params(source: Prism::Source, node_id: Integer, location: Prism::Location, flags: Integer, receiver: T.nilable(Prism::Node), call_operator_loc: T.nilable(Prism::Location), name: Symbol, message_loc: T.nilable(Prism::Location), opening_loc: T.nilable(Prism::Location), arguments: T.nilable(Prism::ArgumentsNode), closing_loc: T.nilable(Prism::Location), equal_loc: T.nilable(Prism::Location), block: T.nilable(T.any(Prism::BlockNode, Prism::BlockArgumentNode))).void }
1145
+ def initialize(source, node_id, location, flags, receiver, call_operator_loc, name, message_loc, opening_loc, arguments, closing_loc, equal_loc, block); end
1140
1146
 
1141
1147
  sig { override.params(visitor: Prism::Visitor).returns(T.untyped) }
1142
1148
  def accept(visitor); end
@@ -1153,8 +1159,8 @@ class Prism::CallNode < Prism::Node
1153
1159
  sig { override.returns(T::Array[T.any(Prism::Node, Prism::Location)]) }
1154
1160
  def comment_targets; end
1155
1161
 
1156
- sig { params(node_id: Integer, location: Prism::Location, flags: Integer, receiver: T.nilable(Prism::Node), call_operator_loc: T.nilable(Prism::Location), name: Symbol, message_loc: T.nilable(Prism::Location), opening_loc: T.nilable(Prism::Location), arguments: T.nilable(Prism::ArgumentsNode), closing_loc: T.nilable(Prism::Location), block: T.nilable(T.any(Prism::BlockNode, Prism::BlockArgumentNode))).returns(Prism::CallNode) }
1157
- def copy(node_id: self.node_id, location: self.location, flags: self.flags, receiver: self.receiver, call_operator_loc: self.call_operator_loc, name: self.name, message_loc: self.message_loc, opening_loc: self.opening_loc, arguments: self.arguments, closing_loc: self.closing_loc, block: self.block); end
1162
+ sig { params(node_id: Integer, location: Prism::Location, flags: Integer, receiver: T.nilable(Prism::Node), call_operator_loc: T.nilable(Prism::Location), name: Symbol, message_loc: T.nilable(Prism::Location), opening_loc: T.nilable(Prism::Location), arguments: T.nilable(Prism::ArgumentsNode), closing_loc: T.nilable(Prism::Location), equal_loc: T.nilable(Prism::Location), block: T.nilable(T.any(Prism::BlockNode, Prism::BlockArgumentNode))).returns(Prism::CallNode) }
1163
+ def copy(node_id: self.node_id, location: self.location, flags: self.flags, receiver: self.receiver, call_operator_loc: self.call_operator_loc, name: self.name, message_loc: self.message_loc, opening_loc: self.opening_loc, arguments: self.arguments, closing_loc: self.closing_loc, equal_loc: self.equal_loc, block: self.block); end
1158
1164
 
1159
1165
  sig { params(keys: T.nilable(T::Array[Symbol])).returns(T::Hash[Symbol, T.untyped]) }
1160
1166
  def deconstruct_keys(keys); end
@@ -1171,6 +1177,9 @@ class Prism::CallNode < Prism::Node
1171
1177
  sig { returns(T.nilable(String)) }
1172
1178
  def closing; end
1173
1179
 
1180
+ sig { returns(T.nilable(String)) }
1181
+ def equal; end
1182
+
1174
1183
  sig { override.returns(T::Array[Prism::Reflection::Field]) }
1175
1184
  def fields; end
1176
1185
 
@@ -3313,10 +3322,15 @@ class Prism::ForwardingParameterNode < Prism::Node
3313
3322
  def type; end
3314
3323
  end
3315
3324
 
3316
- # Represents the use of the `super` keyword without parentheses or arguments.
3325
+ # Represents the use of the `super` keyword without parentheses or arguments, but which might have a block.
3317
3326
  #
3318
3327
  # super
3319
3328
  # ^^^^^
3329
+ #
3330
+ # super { 123 }
3331
+ # ^^^^^^^^^^^^^
3332
+ #
3333
+ # If it has any other arguments, it would be a `SuperNode` instead.
3320
3334
  class Prism::ForwardingSuperNode < Prism::Node
3321
3335
  sig { returns(T.nilable(Prism::BlockNode)) }
3322
3336
  def block; end
@@ -4928,13 +4942,13 @@ class Prism::InterpolatedStringNode < Prism::Node
4928
4942
  sig { returns(T.nilable(Prism::Location)) }
4929
4943
  def opening_loc; end
4930
4944
 
4931
- sig { returns(T::Array[T.any(Prism::StringNode, Prism::EmbeddedStatementsNode, Prism::EmbeddedVariableNode, Prism::InterpolatedStringNode, Prism::XStringNode)]) }
4945
+ sig { returns(T::Array[T.any(Prism::StringNode, Prism::EmbeddedStatementsNode, Prism::EmbeddedVariableNode, Prism::InterpolatedStringNode, Prism::XStringNode, Prism::InterpolatedXStringNode, Prism::SymbolNode, Prism::InterpolatedSymbolNode)]) }
4932
4946
  def parts; end
4933
4947
 
4934
4948
  sig { returns(T.nilable(Prism::Location)) }
4935
4949
  def closing_loc; end
4936
4950
 
4937
- sig { params(source: Prism::Source, node_id: Integer, location: Prism::Location, flags: Integer, opening_loc: T.nilable(Prism::Location), parts: T::Array[T.any(Prism::StringNode, Prism::EmbeddedStatementsNode, Prism::EmbeddedVariableNode, Prism::InterpolatedStringNode, Prism::XStringNode)], closing_loc: T.nilable(Prism::Location)).void }
4951
+ sig { params(source: Prism::Source, node_id: Integer, location: Prism::Location, flags: Integer, opening_loc: T.nilable(Prism::Location), parts: T::Array[T.any(Prism::StringNode, Prism::EmbeddedStatementsNode, Prism::EmbeddedVariableNode, Prism::InterpolatedStringNode, Prism::XStringNode, Prism::InterpolatedXStringNode, Prism::SymbolNode, Prism::InterpolatedSymbolNode)], closing_loc: T.nilable(Prism::Location)).void }
4938
4952
  def initialize(source, node_id, location, flags, opening_loc, parts, closing_loc); end
4939
4953
 
4940
4954
  sig { override.params(visitor: Prism::Visitor).returns(T.untyped) }
@@ -4952,7 +4966,7 @@ class Prism::InterpolatedStringNode < Prism::Node
4952
4966
  sig { override.returns(T::Array[T.any(Prism::Node, Prism::Location)]) }
4953
4967
  def comment_targets; end
4954
4968
 
4955
- sig { params(node_id: Integer, location: Prism::Location, flags: Integer, opening_loc: T.nilable(Prism::Location), parts: T::Array[T.any(Prism::StringNode, Prism::EmbeddedStatementsNode, Prism::EmbeddedVariableNode, Prism::InterpolatedStringNode, Prism::XStringNode)], closing_loc: T.nilable(Prism::Location)).returns(Prism::InterpolatedStringNode) }
4969
+ sig { params(node_id: Integer, location: Prism::Location, flags: Integer, opening_loc: T.nilable(Prism::Location), parts: T::Array[T.any(Prism::StringNode, Prism::EmbeddedStatementsNode, Prism::EmbeddedVariableNode, Prism::InterpolatedStringNode, Prism::XStringNode, Prism::InterpolatedXStringNode, Prism::SymbolNode, Prism::InterpolatedSymbolNode)], closing_loc: T.nilable(Prism::Location)).returns(Prism::InterpolatedStringNode) }
4956
4970
  def copy(node_id: self.node_id, location: self.location, flags: self.flags, opening_loc: self.opening_loc, parts: self.parts, closing_loc: self.closing_loc); end
4957
4971
 
4958
4972
  sig { params(keys: T.nilable(T::Array[Symbol])).returns(T::Hash[Symbol, T.untyped]) }
@@ -7964,6 +7978,8 @@ end
7964
7978
  #
7965
7979
  # super foo, bar
7966
7980
  # ^^^^^^^^^^^^^^
7981
+ #
7982
+ # If no arguments are provided (except for a block), it would be a `ForwardingSuperNode` instead.
7967
7983
  class Prism::SuperNode < Prism::Node
7968
7984
  sig { returns(Prism::Location) }
7969
7985
  def keyword_loc; end
@@ -0,0 +1,23 @@
1
+ # typed: strict
2
+
3
+ class Prism::Translation::Parser33 < Prism::Translation::Parser
4
+ sig { override.returns(Integer) }
5
+ def version; end
6
+ end
7
+
8
+ class Prism::Translation::Parser34 < Prism::Translation::Parser
9
+ sig { override.returns(Integer) }
10
+ def version; end
11
+ end
12
+
13
+ class Prism::Translation::Parser40 < Prism::Translation::Parser
14
+ sig { override.returns(Integer) }
15
+ def version; end
16
+ end
17
+
18
+ Prism::Translation::Parser35 = Prism::Translation::Parser40
19
+
20
+ class Prism::Translation::Parser40 < Prism::Translation::Parser
21
+ sig { override.returns(Integer) }
22
+ def version; end
23
+ end
data/rbi/prism.rbi CHANGED
@@ -16,9 +16,6 @@ module Prism
16
16
  sig { params(source: String, options: T::Hash[Symbol, T.untyped]).returns(Prism::LexCompat::Result) }
17
17
  def self.lex_compat(source, **options); end
18
18
 
19
- sig { params(source: String).returns(T::Array[T.untyped]) }
20
- def self.lex_ripper(source); end
21
-
22
19
  sig { params(source: String, serialized: String, freeze: T.nilable(T::Boolean)).returns(Prism::ParseResult) }
23
20
  def self.load(source, serialized, freeze = false); end
24
21
 
data/sig/prism/dsl.rbs CHANGED
@@ -44,7 +44,7 @@ module Prism
44
44
 
45
45
  def call_and_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?operator_loc: Location, ?value: Prism::node) -> CallAndWriteNode
46
46
 
47
- def call_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?name: Symbol, ?message_loc: Location?, ?opening_loc: Location?, ?arguments: ArgumentsNode?, ?closing_loc: Location?, ?block: BlockNode | BlockArgumentNode | nil) -> CallNode
47
+ def call_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?name: Symbol, ?message_loc: Location?, ?opening_loc: Location?, ?arguments: ArgumentsNode?, ?closing_loc: Location?, ?equal_loc: Location?, ?block: BlockNode | BlockArgumentNode | nil) -> CallNode
48
48
 
49
49
  def call_operator_write_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?message_loc: Location?, ?read_name: Symbol, ?write_name: Symbol, ?binary_operator: Symbol, ?binary_operator_loc: Location, ?value: Prism::node) -> CallOperatorWriteNode
50
50
 
@@ -176,7 +176,7 @@ module Prism
176
176
 
177
177
  def interpolated_regular_expression_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location) -> InterpolatedRegularExpressionNode
178
178
 
179
- def interpolated_string_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode], ?closing_loc: Location?) -> InterpolatedStringNode
179
+ def interpolated_string_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode], ?closing_loc: Location?) -> InterpolatedStringNode
180
180
 
181
181
  def interpolated_symbol_node: (?source: Source, ?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode], ?closing_loc: Location?) -> InterpolatedSymbolNode
182
182
 
data/sig/prism/node.rbs CHANGED
@@ -16,6 +16,7 @@ module Prism
16
16
  def child_nodes: () -> Array[Prism::node?]
17
17
  def comment_targets: () -> Array[Prism::node | Location]
18
18
  def compact_child_nodes: () -> Array[Prism::node]
19
+ def each_child_node: () { (Prism::node) -> void } -> void | () -> Enumerator[Prism::node]
19
20
  def self.fields: () -> Array[Prism::Reflection::Field]
20
21
  def type: () -> Symbol
21
22
  def self.type: () -> Symbol
@@ -28,6 +29,9 @@ module Prism
28
29
  def to_dot: () -> String
29
30
  def tunnel: (Integer line, Integer column) -> Array[Prism::node]
30
31
  def breadth_first_search: () { (Prism::node) -> bool } -> Prism::node?
32
+ alias find breadth_first_search
33
+ def breadth_first_search_all: () { (Prism::node) -> bool } -> Array[Prism::node]
34
+ alias find_all breadth_first_search_all
31
35
  def newline!: (Array[untyped]) -> void
32
36
 
33
37
  def save: (_Repository repository) -> void
@@ -553,20 +557,23 @@ module Prism
553
557
  attr_reader opening_loc: Location?
554
558
  attr_reader arguments: ArgumentsNode?
555
559
  attr_reader closing_loc: Location?
560
+ attr_reader equal_loc: Location?
556
561
  attr_reader block: BlockNode | BlockArgumentNode | nil
557
562
 
558
563
  def save_call_operator_loc: (_Repository repository) -> void
559
564
  def save_message_loc: (_Repository repository) -> void
560
565
  def save_opening_loc: (_Repository repository) -> void
561
566
  def save_closing_loc: (_Repository repository) -> void
567
+ def save_equal_loc: (_Repository repository) -> void
562
568
 
563
- def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Symbol name, Location? message_loc, Location? opening_loc, ArgumentsNode? arguments, Location? closing_loc, BlockNode | BlockArgumentNode | nil block) -> void
564
- def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?name: Symbol, ?message_loc: Location?, ?opening_loc: Location?, ?arguments: ArgumentsNode?, ?closing_loc: Location?, ?block: BlockNode | BlockArgumentNode | nil) -> CallNode
565
- def deconstruct_keys: (Array[Symbol] keys) -> { node_id: Integer, location: Location, receiver: Prism::node?, call_operator_loc: Location?, name: Symbol, message_loc: Location?, opening_loc: Location?, arguments: ArgumentsNode?, closing_loc: Location?, block: BlockNode | BlockArgumentNode | nil }
569
+ def initialize: (Source source, Integer node_id, Location location, Integer flags, Prism::node? receiver, Location? call_operator_loc, Symbol name, Location? message_loc, Location? opening_loc, ArgumentsNode? arguments, Location? closing_loc, Location? equal_loc, BlockNode | BlockArgumentNode | nil block) -> void
570
+ def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?receiver: Prism::node?, ?call_operator_loc: Location?, ?name: Symbol, ?message_loc: Location?, ?opening_loc: Location?, ?arguments: ArgumentsNode?, ?closing_loc: Location?, ?equal_loc: Location?, ?block: BlockNode | BlockArgumentNode | nil) -> CallNode
571
+ def deconstruct_keys: (Array[Symbol] keys) -> { node_id: Integer, location: Location, receiver: Prism::node?, call_operator_loc: Location?, name: Symbol, message_loc: Location?, opening_loc: Location?, arguments: ArgumentsNode?, closing_loc: Location?, equal_loc: Location?, block: BlockNode | BlockArgumentNode | nil }
566
572
  def call_operator: () -> String?
567
573
  def message: () -> String?
568
574
  def opening: () -> String?
569
575
  def closing: () -> String?
576
+ def equal: () -> String?
570
577
  def type: () -> :call_node
571
578
  | ...
572
579
  def self.type: () -> :call_node
@@ -1526,10 +1533,15 @@ module Prism
1526
1533
  def self.type: () -> :forwarding_parameter_node
1527
1534
  end
1528
1535
 
1529
- # Represents the use of the `super` keyword without parentheses or arguments.
1536
+ # Represents the use of the `super` keyword without parentheses or arguments, but which might have a block.
1530
1537
  #
1531
1538
  # super
1532
1539
  # ^^^^^
1540
+ #
1541
+ # super { 123 }
1542
+ # ^^^^^^^^^^^^^
1543
+ #
1544
+ # If it has any other arguments, it would be a `SuperNode` instead.
1533
1545
  class ForwardingSuperNode < Node
1534
1546
  include _Node
1535
1547
 
@@ -2254,15 +2266,15 @@ module Prism
2254
2266
  def mutable?: () -> bool
2255
2267
 
2256
2268
  attr_reader opening_loc: Location?
2257
- attr_reader parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode]
2269
+ attr_reader parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode]
2258
2270
  attr_reader closing_loc: Location?
2259
2271
 
2260
2272
  def save_opening_loc: (_Repository repository) -> void
2261
2273
  def save_closing_loc: (_Repository repository) -> void
2262
2274
 
2263
- def initialize: (Source source, Integer node_id, Location location, Integer flags, Location? opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode] parts, Location? closing_loc) -> void
2264
- def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode], ?closing_loc: Location?) -> InterpolatedStringNode
2265
- def deconstruct_keys: (Array[Symbol] keys) -> { node_id: Integer, location: Location, opening_loc: Location?, parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode], closing_loc: Location? }
2275
+ def initialize: (Source source, Integer node_id, Location location, Integer flags, Location? opening_loc, Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode] parts, Location? closing_loc) -> void
2276
+ def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?opening_loc: Location?, ?parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode], ?closing_loc: Location?) -> InterpolatedStringNode
2277
+ def deconstruct_keys: (Array[Symbol] keys) -> { node_id: Integer, location: Location, opening_loc: Location?, parts: Array[StringNode | EmbeddedStatementsNode | EmbeddedVariableNode | InterpolatedStringNode | XStringNode | InterpolatedXStringNode | SymbolNode | InterpolatedSymbolNode], closing_loc: Location? }
2266
2278
  def opening: () -> String?
2267
2279
  def closing: () -> String?
2268
2280
  def type: () -> :interpolated_string_node
@@ -3594,6 +3606,8 @@ module Prism
3594
3606
  #
3595
3607
  # super foo, bar
3596
3608
  # ^^^^^^^^^^^^^^
3609
+ #
3610
+ # If no arguments are provided (except for a block), it would be a `ForwardingSuperNode` instead.
3597
3611
  class SuperNode < Node
3598
3612
  include _Node
3599
3613
 
@@ -14,6 +14,7 @@ module Prism
14
14
  def encoding: () -> Encoding
15
15
  def lines: () -> Array[String]
16
16
  def slice: (Integer byte_offset, Integer length) -> String
17
+ def byte_offset: (Integer line, Integer column) -> Integer
17
18
  def line: (Integer byte_offset) -> Integer
18
19
  def line_start: (Integer byte_offset) -> Integer
19
20
  def line_end: (Integer byte_offset) -> Integer