Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ jobs:
with:
ruby-version: "3.4"
bundler-cache: true
- name: Check Sorbet
run: bundle exec rake typecheck:tapioca typecheck:sorbet
# - name: Check Sorbet
# run: bundle exec rake typecheck:tapioca typecheck:sorbet
- name: Check Steep
run: bundle exec rake typecheck:steep
- name: Check field kinds
Expand Down
51 changes: 11 additions & 40 deletions config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,6 @@ nodes:
- GlobalVariableReadNode
- BackReferenceReadNode
- NumberedReferenceReadNode
- on error: SymbolNode # alias $a b
- on error: MissingNode # alias $a 42
comment: |
Represents the old name of the global variable that can be used before aliasing.

Expand Down Expand Up @@ -856,8 +854,6 @@ nodes:
kind:
- SymbolNode
- InterpolatedSymbolNode
- on error: GlobalVariableReadNode # alias a $b
- on error: MissingNode # alias a 42
comment: |
Represents the old name of the method that will be aliased.

Expand Down Expand Up @@ -1871,7 +1867,6 @@ nodes:
kind:
- ConstantReadNode
- ConstantPathNode
- on error: CallNode # class 0.X end
- name: inheritance_operator_loc
type: location?
comment: |
Expand Down Expand Up @@ -2425,6 +2420,15 @@ nodes:
^^^^^^
bar
end
- name: ErrorRecoveryNode
fields:
- name: unexpected
type: node?
kind: Node
comment: |
The unexpected node that was found in the tree, if there was one.
comment: |
Represents a node that is either missing or unexpected and results in a syntax error.
- name: FalseNode
comment: |
Represents the use of the literal `false` keyword.
Expand Down Expand Up @@ -2467,9 +2471,7 @@ nodes:
^^^^^^
- name: right
type: node
kind:
- SplatNode
- on error: MissingNode
kind: SplatNode
comment: |
Represents the second wildcard node in the pattern.

Expand Down Expand Up @@ -2552,9 +2554,6 @@ nodes:
- CallTargetNode
- IndexTargetNode
- MultiTargetNode
- on error: BackReferenceReadNode # for $& in a end
- on error: NumberedReferenceReadNode # for $1 in a end
- on error: MissingNode # for in 1..10; end
comment: |
The index expression for `for` loops.

Expand Down Expand Up @@ -3308,10 +3307,6 @@ nodes:
- EmbeddedStatementsNode
- EmbeddedVariableNode
- InterpolatedStringNode # `"a" "#{b}"`
- on error: XStringNode # `<<`FOO` "bar"
- on error: InterpolatedXStringNode
- on error: SymbolNode
- on error: InterpolatedSymbolNode
- name: closing_loc
type: location?
newline: parts
Expand Down Expand Up @@ -3689,9 +3684,6 @@ nodes:

/(?<foo>bar)/ =~ baz
^^^^^^^^^^^^^^^^^^^^
- name: MissingNode
comment: |
Represents a node that is missing from the source and results in a syntax error.
- name: ModuleNode
fields:
- name: locals
Expand All @@ -3703,7 +3695,6 @@ nodes:
kind:
- ConstantReadNode
- ConstantPathNode
- on error: MissingNode # module Parent module end
- name: body
type: node?
kind:
Expand Down Expand Up @@ -3733,8 +3724,6 @@ nodes:
- IndexTargetNode
- MultiTargetNode
- RequiredParameterNode # def m((a,b)); end
- on error: BackReferenceReadNode # a, (b, $&) = z
- on error: NumberedReferenceReadNode # a, (b, $1) = z
comment: |
Represents the targets expressions before a splat node.

Expand Down Expand Up @@ -3778,8 +3767,6 @@ nodes:
- IndexTargetNode
- MultiTargetNode
- RequiredParameterNode # def m((*,b)); end
- on error: BackReferenceReadNode # a, (*, $&) = z
- on error: NumberedReferenceReadNode # a, (*, $1) = z
comment: |
Represents the targets expressions after a splat node.

Expand Down Expand Up @@ -3823,8 +3810,6 @@ nodes:
- CallTargetNode
- IndexTargetNode
- MultiTargetNode
- on error: BackReferenceReadNode # $&, = z
- on error: NumberedReferenceReadNode # $1, = z
comment: |
Represents the targets expressions before a splat node.

Expand Down Expand Up @@ -3867,8 +3852,6 @@ nodes:
- CallTargetNode
- IndexTargetNode
- MultiTargetNode
- on error: BackReferenceReadNode # *, $& = z
- on error: NumberedReferenceReadNode # *, $1 = z
comment: |
Represents the targets expressions after a splat node.

Expand Down Expand Up @@ -4066,14 +4049,6 @@ nodes:
kind:
- RequiredParameterNode
- MultiTargetNode
# On parsing error of `f(**kwargs, ...)` or `f(**nil, ...)`, the keyword_rest value is moved here:
- on error: KeywordRestParameterNode
- on error: NoKeywordsParameterNode
# On parsing error of `f(..., ...)`, the first forwarding parameter is moved here:
- on error: ForwardingParameterNode
# On parsing error of `f(&nil, &foo)`/`f(&foo, &nil)`, the first forwarding parameter is moved here:
- on error: BlockParameterNode
- on error: NoBlockParameterNode
- name: keywords
type: node[]
kind:
Expand Down Expand Up @@ -4160,7 +4135,6 @@ nodes:
- BackReferenceReadNode # foo in ^$&
- NumberedReferenceReadNode # foo in ^$1
- ItLocalVariableReadNode # proc { 1 in ^it }
- on error: MissingNode # foo in ^Bar
comment: |
The variable used in the pinned expression

Expand Down Expand Up @@ -4243,7 +4217,7 @@ nodes:

1...foo
^^^
If neither right-hand or left-hand side was included, this will be a MissingNode.
If neither right-hand or left-hand side was included, this will be an ErrorRecoveryNode.
- name: operator_loc
type: location
comment: |
Expand Down Expand Up @@ -4358,9 +4332,6 @@ nodes:
- ConstantPathTargetNode
- CallTargetNode
- IndexTargetNode
- on error: BackReferenceReadNode # => begin; rescue => $&; end
- on error: NumberedReferenceReadNode # => begin; rescue => $1; end
- on error: MissingNode # begin; rescue =>; end
- name: then_keyword_loc
type: location?
- name: statements
Expand Down
2 changes: 1 addition & 1 deletion docs/mapping.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,6 @@ The following table shows how the various CRuby nodes are mapped to prism nodes.
| `NODE_ARYPTN` | `PM_ARRAY_PATTERN_NODE` |
| `NODE_HSHPTN` | `PM_HASH_PATTERN_NODE` |
| `NODE_FNDPTN` | `PM_FIND_PATTERN_NODE` |
| `NODE_ERROR` | `PM_MISSING_NODE` |
| `NODE_ERROR` | `PM_ERROR_RECOVERY_NODE` |
| `NODE_LAST` | |
```
8 changes: 4 additions & 4 deletions lib/prism/node_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,10 @@ class ConstantPathNode < Node
# local variable
class DynamicPartsInConstantPathError < StandardError; end

# An error class raised when missing nodes are found while computing a
# An error class raised when error recovery nodes are found while computing a
# constant path's full name. For example:
# Foo:: -> raises because the constant path is missing the last part
class MissingNodesInConstantPathError < StandardError; end
class ErrorRecoveryNodesInConstantPathError < StandardError; end

# Returns the list of parts for the full name of this constant path.
# For example: [:Foo, :Bar]
Expand All @@ -237,7 +237,7 @@ def full_name_parts
while current.is_a?(ConstantPathNode)
name = current.name
if name.nil?
raise MissingNodesInConstantPathError, "Constant path contains missing nodes. Cannot compute full name"
raise ErrorRecoveryNodesInConstantPathError, "Constant path contains error recovery nodes. Cannot compute full name"
end

parts.unshift(name)
Expand Down Expand Up @@ -277,7 +277,7 @@ def full_name_parts
end

if (name = self.name).nil?
raise ConstantPathNode::MissingNodesInConstantPathError, "Constant target path contains missing nodes. Cannot compute full name"
raise ConstantPathNode::ErrorRecoveryNodesInConstantPathError, "Constant target path contains error recovery nodes. Cannot compute full name"
end

parts.push(name)
Expand Down
2 changes: 1 addition & 1 deletion lib/prism/translation/parser/compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1324,7 +1324,7 @@ def visit_match_write_node(node)
# A node that is missing from the syntax tree. This is only used in the
# case of a syntax error. The parser gem doesn't have such a concept, so
# we invent our own here.
def visit_missing_node(node)
def visit_error_recovery_node(node)
::AST::Node.new(:missing, [], location: ::Parser::Source::Map.new(srange(node.location)))
end

Expand Down
4 changes: 2 additions & 2 deletions lib/prism/translation/ripper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2507,8 +2507,8 @@ def visit_match_write_node(node)

# A node that is missing from the syntax tree. This is only used in the
# case of a syntax error.
def visit_missing_node(node)
raise "Cannot visit missing nodes directly."
def visit_error_recovery_node(node)
raise "Cannot visit error recovery nodes directly."
end

# module Foo; end
Expand Down
4 changes: 2 additions & 2 deletions lib/prism/translation/ruby_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1071,8 +1071,8 @@ def visit_match_write_node(node)
# A node that is missing from the syntax tree. This is only used in the
# case of a syntax error. The parser gem doesn't have such a concept, so
# we invent our own here.
def visit_missing_node(node)
raise "Cannot visit missing node directly"
def visit_error_recovery_node(node)
raise "Cannot visit error recovery node directly"
end

# module Foo; end
Expand Down
2 changes: 1 addition & 1 deletion rakelib/lint.rake
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ task :lint do
exit(1)
end

if (uncommented = nodes.select { |node| !%w[MissingNode ProgramNode].include?(node.fetch("name")) && !node.fetch("comment").match?(/^\s{4}/) }).any?
if (uncommented = nodes.select { |node| !%w[ErrorRecoveryNode ProgramNode].include?(node.fetch("name")) && !node.fetch("comment").match?(/^\s{4}/) }).any?
names = uncommented.map { |node| node.fetch("name") }
warn("Expected all nodes to have an example, missing comments for #{names.join(", ")}")
exit(1)
Expand Down
6 changes: 3 additions & 3 deletions rbi/generated/prism/compiler.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions rbi/generated/prism/dispatcher.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions rbi/generated/prism/dot_visitor.rbi

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading