Skip to content

Commit bf17817

Browse files
Rename MissingNode to ErrorRecoveryNode
1 parent 8c32f51 commit bf17817

8 files changed

Lines changed: 43 additions & 43 deletions

File tree

config.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ nodes:
812812
- BackReferenceReadNode
813813
- NumberedReferenceReadNode
814814
- on error: SymbolNode # alias $a b
815-
- on error: MissingNode # alias $a 42
815+
- on error: ErrorRecoveryNode # alias $a 42
816816
comment: |
817817
Represents the old name of the global variable that can be used before aliasing.
818818
@@ -854,7 +854,7 @@ nodes:
854854
- SymbolNode
855855
- InterpolatedSymbolNode
856856
- on error: GlobalVariableReadNode # alias a $b
857-
- on error: MissingNode # alias a 42
857+
- on error: ErrorRecoveryNode # alias a 42
858858
comment: |
859859
Represents the old name of the method that will be aliased.
860860
@@ -2466,7 +2466,7 @@ nodes:
24662466
type: node
24672467
kind:
24682468
- SplatNode
2469-
- on error: MissingNode
2469+
- on error: ErrorRecoveryNode
24702470
comment: |
24712471
Represents the second wildcard node in the pattern.
24722472
@@ -2551,7 +2551,7 @@ nodes:
25512551
- MultiTargetNode
25522552
- on error: BackReferenceReadNode # for $& in a end
25532553
- on error: NumberedReferenceReadNode # for $1 in a end
2554-
- on error: MissingNode # for in 1..10; end
2554+
- on error: ErrorRecoveryNode # for in 1..10; end
25552555
comment: |
25562556
The index expression for `for` loops.
25572557
@@ -3686,7 +3686,7 @@ nodes:
36863686
36873687
/(?<foo>bar)/ =~ baz
36883688
^^^^^^^^^^^^^^^^^^^^
3689-
- name: MissingNode
3689+
- name: ErrorRecoveryNode
36903690
comment: |
36913691
Represents a node that is missing from the source and results in a syntax error.
36923692
- name: ModuleNode
@@ -3700,7 +3700,7 @@ nodes:
37003700
kind:
37013701
- ConstantReadNode
37023702
- ConstantPathNode
3703-
- on error: MissingNode # module Parent module end
3703+
- on error: ErrorRecoveryNode # module Parent module end
37043704
- name: body
37053705
type: node?
37063706
kind:
@@ -4140,7 +4140,7 @@ nodes:
41404140
- BackReferenceReadNode # foo in ^$&
41414141
- NumberedReferenceReadNode # foo in ^$1
41424142
- ItLocalVariableReadNode # proc { 1 in ^it }
4143-
- on error: MissingNode # foo in ^Bar
4143+
- on error: ErrorRecoveryNode # foo in ^Bar
41444144
comment: |
41454145
The variable used in the pinned expression
41464146
@@ -4223,7 +4223,7 @@ nodes:
42234223
42244224
1...foo
42254225
^^^
4226-
If neither right-hand or left-hand side was included, this will be a MissingNode.
4226+
If neither right-hand or left-hand side was included, this will be an ErrorRecoveryNode.
42274227
- name: operator_loc
42284228
type: location
42294229
comment: |
@@ -4340,7 +4340,7 @@ nodes:
43404340
- IndexTargetNode
43414341
- on error: BackReferenceReadNode # => begin; rescue => $&; end
43424342
- on error: NumberedReferenceReadNode # => begin; rescue => $1; end
4343-
- on error: MissingNode # begin; rescue =>; end
4343+
- on error: ErrorRecoveryNode # begin; rescue =>; end
43444344
- name: then_keyword_loc
43454345
type: location?
43464346
- name: statements

lib/prism/node_ext.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def child
208208
if name
209209
ConstantReadNode.new(source, -1, name_loc, 0, name)
210210
else
211-
MissingNode.new(source, -1, location, 0)
211+
ErrorRecoveryNode.new(source, -1, location, 0)
212212
end
213213
end
214214
end
@@ -249,7 +249,7 @@ def child
249249
if name
250250
ConstantReadNode.new(source, -1, name_loc, 0, name)
251251
else
252-
MissingNode.new(source, -1, location, 0)
252+
ErrorRecoveryNode.new(source, -1, location, 0)
253253
end
254254
end
255255
end

rakelib/lint.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ task :lint do
2929
exit(1)
3030
end
3131

32-
if (uncommented = nodes.select { |node| !%w[MissingNode ProgramNode].include?(node.fetch("name")) && !node.fetch("comment").match?(/^\s{4}/) }).any?
32+
if (uncommented = nodes.select { |node| !%w[ErrorRecoveryNode ProgramNode].include?(node.fetch("name")) && !node.fetch("comment").match?(/^\s{4}/) }).any?
3333
names = uncommented.map { |node| node.fetch("name") }
3434
warn("Expected all nodes to have an example, missing comments for #{names.join(", ")}")
3535
exit(1)

sig/prism/node_ext.rbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,18 @@ module Prism
6060
class DynamicPartsInConstantPathError < StandardError
6161
end
6262

63-
class MissingNodesInConstantPathError < StandardError
63+
class ErrorRecoveryNodesInConstantPathError < StandardError
6464
end
6565

6666
def full_name_parts: () -> Array[Symbol]
6767
def full_name: () -> String
68-
def child: () -> (ConstantReadNode | MissingNode)
68+
def child: () -> (ConstantReadNode | ErrorRecoveryNode)
6969
end
7070

7171
class ConstantPathTargetNode < Node
7272
def full_name_parts: () -> Array[Symbol]
7373
def full_name: () -> String
74-
def child: () -> (ConstantReadNode | MissingNode)
74+
def child: () -> (ConstantReadNode | ErrorRecoveryNode)
7575
end
7676

7777
class ConstantTargetNode < Node

src/prism.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1958,14 +1958,14 @@ pm_node_alloc(PRISM_ATTRIBUTE_UNUSED pm_parser_t *parser, size_t size) {
19581958
#define PM_NODE_INIT_NODE_TOKEN(parser_, type_, flags_, node_, token_) PM_NODE_INIT(parser_, type_, flags_, PM_NODE_START(node_), PM_TOKEN_END(token_))
19591959

19601960
/**
1961-
* Allocate a new MissingNode node.
1961+
* Allocate a new ErrorRecoveryNode node to represent a missing node.
19621962
*/
1963-
static pm_missing_node_t *
1963+
static pm_error_recovery_node_t *
19641964
pm_missing_node_create(pm_parser_t *parser, const uint8_t *start, const uint8_t *end) {
1965-
pm_missing_node_t *node = PM_NODE_ALLOC(parser, pm_missing_node_t);
1965+
pm_error_recovery_node_t *node = PM_NODE_ALLOC(parser, pm_error_recovery_node_t);
19661966

1967-
*node = (pm_missing_node_t) {
1968-
.base = PM_NODE_INIT(parser, PM_MISSING_NODE, 0, start, end)
1967+
*node = (pm_error_recovery_node_t) {
1968+
.base = PM_NODE_INIT(parser, PM_ERROR_RECOVERY_NODE, 0, start, end)
19691969
};
19701970

19711971
return node;
@@ -3788,7 +3788,7 @@ pm_find_pattern_node_create(pm_parser_t *parser, pm_node_list_t *nodes) {
37883788
}
37893789

37903790
#if PRISM_SERIALIZE_ONLY_SEMANTICS_FIELDS
3791-
// FindPatternNode#right is typed as SplatNode in this case, so replace the potential MissingNode with a SplatNode.
3791+
// FindPatternNode#right is typed as SplatNode in this case, so replace the potential ErrorRecoveryNode with a SplatNode.
37923792
// The resulting AST will anyway be ignored, but this file still needs to compile.
37933793
pm_splat_node_t *right_splat_node = PM_NODE_TYPE_P(right, PM_SPLAT_NODE) ? (pm_splat_node_t *) right : left_splat_node;
37943794
#else
@@ -12677,7 +12677,7 @@ parse_unwriteable_target(pm_parser_t *parser, pm_node_t *target) {
1267712677
static pm_node_t *
1267812678
parse_target(pm_parser_t *parser, pm_node_t *target, bool multiple, bool splat_parent) {
1267912679
switch (PM_NODE_TYPE(target)) {
12680-
case PM_MISSING_NODE:
12680+
case PM_ERROR_RECOVERY_NODE:
1268112681
return target;
1268212682
case PM_SOURCE_ENCODING_NODE:
1268312683
case PM_FALSE_NODE:
@@ -12867,7 +12867,7 @@ parse_shareable_constant_write(pm_parser_t *parser, pm_node_t *write) {
1286712867
static pm_node_t *
1286812868
parse_write(pm_parser_t *parser, pm_node_t *target, pm_token_t *operator, pm_node_t *value) {
1286912869
switch (PM_NODE_TYPE(target)) {
12870-
case PM_MISSING_NODE:
12870+
case PM_ERROR_RECOVERY_NODE:
1287112871
pm_node_destroy(parser, value);
1287212872
return target;
1287312873
case PM_CLASS_VARIABLE_READ_NODE: {
@@ -13220,7 +13220,7 @@ parse_statements(pm_parser_t *parser, pm_context_t context, uint16_t depth) {
1322013220
// we were unable to parse an expression, then we will skip past this
1322113221
// token and continue parsing the statements list. Otherwise we'll add
1322213222
// an error and continue parsing the statements list.
13223-
if (PM_NODE_TYPE_P(node, PM_MISSING_NODE)) {
13223+
if (PM_NODE_TYPE_P(node, PM_ERROR_RECOVERY_NODE)) {
1322413224
parser_lex(parser);
1322513225

1322613226
// If we are at the end of the file, then we need to stop parsing
@@ -13661,7 +13661,7 @@ parse_arguments(pm_parser_t *parser, pm_arguments_t *arguments, bool accepts_for
1366113661
parsed_first_argument = true;
1366213662

1366313663
// If parsing the argument failed, we need to stop parsing arguments.
13664-
if (PM_NODE_TYPE_P(argument, PM_MISSING_NODE) || parser->recovering) break;
13664+
if (PM_NODE_TYPE_P(argument, PM_ERROR_RECOVERY_NODE) || parser->recovering) break;
1366513665

1366613666
// If the terminator of these arguments is not EOF, then we have a
1366713667
// specific token we're looking for. In that case we can accept a
@@ -16729,7 +16729,7 @@ parse_pattern_primitive(pm_parser_t *parser, pm_constant_id_list_t *captures, pm
1672916729
// Call nodes (arithmetic operations) are not allowed in patterns
1673016730
if (PM_NODE_TYPE(node) == PM_CALL_NODE) {
1673116731
pm_parser_err_node(parser, node, diag_id);
16732-
pm_missing_node_t *missing_node = pm_missing_node_create(parser, node->location.start, node->location.end);
16732+
pm_error_recovery_node_t *missing_node = pm_missing_node_create(parser, node->location.start, node->location.end);
1673316733

1673416734
pm_node_unreference(parser, node);
1673516735
pm_node_destroy(parser, node);
@@ -17521,7 +17521,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
1752117521
}
1752217522

1752317523
pm_array_node_elements_append(array, element);
17524-
if (PM_NODE_TYPE_P(element, PM_MISSING_NODE)) break;
17524+
if (PM_NODE_TYPE_P(element, PM_ERROR_RECOVERY_NODE)) break;
1752517525
}
1752617526

1752717527
accept1(parser, PM_TOKEN_NEWLINE);
@@ -17697,7 +17697,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
1769717697

1769817698
// If we couldn't parse an expression at all, then we need to
1769917699
// bail out of the loop.
17700-
if (PM_NODE_TYPE_P(node, PM_MISSING_NODE)) break;
17700+
if (PM_NODE_TYPE_P(node, PM_ERROR_RECOVERY_NODE)) break;
1770117701

1770217702
// If we successfully parsed a statement, then we are going to
1770317703
// need terminator to delimit them.
@@ -18248,14 +18248,14 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
1824818248
pm_splat_node_t *splat_node = pm_splat_node_create(parser, &operator, expression);
1824918249
pm_when_node_conditions_append(when_node, UP(splat_node));
1825018250

18251-
if (PM_NODE_TYPE_P(expression, PM_MISSING_NODE)) break;
18251+
if (PM_NODE_TYPE_P(expression, PM_ERROR_RECOVERY_NODE)) break;
1825218252
} else {
1825318253
pm_node_t *condition = parse_value_expression(parser, PM_BINDING_POWER_DEFINED, false, false, PM_ERR_CASE_EXPRESSION_AFTER_WHEN, (uint16_t) (depth + 1));
1825418254
pm_when_node_conditions_append(when_node, condition);
1825518255

1825618256
// If we found a missing node, then this is a syntax
1825718257
// error and we should stop looping.
18258-
if (PM_NODE_TYPE_P(condition, PM_MISSING_NODE)) break;
18258+
if (PM_NODE_TYPE_P(condition, PM_ERROR_RECOVERY_NODE)) break;
1825918259

1826018260
// If this is a string node, then we need to mark it
1826118261
// as frozen because when clause strings are frozen.
@@ -19134,7 +19134,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
1913419134
pm_undef_node_t *undef = pm_undef_node_create(parser, &parser->previous);
1913519135
pm_node_t *name = parse_undef_argument(parser, (uint16_t) (depth + 1));
1913619136

19137-
if (PM_NODE_TYPE_P(name, PM_MISSING_NODE)) {
19137+
if (PM_NODE_TYPE_P(name, PM_ERROR_RECOVERY_NODE)) {
1913819138
pm_node_destroy(parser, name);
1913919139
} else {
1914019140
pm_undef_node_append(undef, name);
@@ -19144,7 +19144,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
1914419144
parser_lex(parser);
1914519145
name = parse_undef_argument(parser, (uint16_t) (depth + 1));
1914619146

19147-
if (PM_NODE_TYPE_P(name, PM_MISSING_NODE)) {
19147+
if (PM_NODE_TYPE_P(name, PM_ERROR_RECOVERY_NODE)) {
1914819148
pm_node_destroy(parser, name);
1914919149
break;
1915019150
}
@@ -19218,7 +19218,7 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
1921819218

1921919219
// If we can recover from a syntax error that occurred while parsing
1922019220
// the name of the module, then we'll handle that here.
19221-
if (PM_NODE_TYPE_P(constant_path, PM_MISSING_NODE)) {
19221+
if (PM_NODE_TYPE_P(constant_path, PM_ERROR_RECOVERY_NODE)) {
1922219222
pop_block_exits(parser, previous_block_exits);
1922319223
pm_node_list_free(&current_block_exits);
1922419224

@@ -20291,7 +20291,7 @@ parse_assignment_values(pm_parser_t *parser, pm_binding_power_t previous_binding
2029120291
pm_node_t *element = parse_starred_expression(parser, binding_power, false, PM_ERR_ARRAY_ELEMENT, (uint16_t) (depth + 1));
2029220292

2029320293
pm_array_node_elements_append(array, element);
20294-
if (PM_NODE_TYPE_P(element, PM_MISSING_NODE)) break;
20294+
if (PM_NODE_TYPE_P(element, PM_ERROR_RECOVERY_NODE)) break;
2029520295

2029620296
parse_assignment_value_local(parser, element);
2029720297
}
@@ -21584,7 +21584,7 @@ parse_expression(pm_parser_t *parser, pm_binding_power_t binding_power, bool acc
2158421584
pm_node_t *node = parse_expression_prefix(parser, binding_power, accepts_command_call, accepts_label, diag_id, depth);
2158521585

2158621586
switch (PM_NODE_TYPE(node)) {
21587-
case PM_MISSING_NODE:
21587+
case PM_ERROR_RECOVERY_NODE:
2158821588
// If we found a syntax error, then the type of node returned by
2158921589
// parse_expression_prefix is going to be a missing node.
2159021590
return node;

templates/lib/prism/dsl.rb.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ module Prism
127127
# The default node that gets attached to nodes if no node is specified for a
128128
# required node field.
129129
def default_node(source, location)
130-
MissingNode.new(source, -1, location, 0)
130+
ErrorRecoveryNode.new(source, -1, location, 0)
131131
end
132132
end
133133
end

test/prism/result/error_recovery_test.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def test_alias_global_variable_node_old_name_missing
1717
refute result.success?
1818

1919
node = result.value.statements.body.first
20-
assert_kind_of MissingNode, node.old_name
20+
assert_kind_of ErrorRecoveryNode, node.old_name
2121
end
2222

2323
def test_alias_method_node_old_name_global_variable
@@ -33,7 +33,7 @@ def test_alias_method_node_old_name_missing
3333
refute result.success?
3434

3535
node = result.value.statements.body.first
36-
assert_kind_of MissingNode, node.old_name
36+
assert_kind_of ErrorRecoveryNode, node.old_name
3737
end
3838

3939
def test_class_node_constant_path_call
@@ -65,7 +65,7 @@ def test_for_node_index_missing
6565
refute result.success?
6666

6767
node = result.value.statements.body.first
68-
assert_kind_of MissingNode, node.index
68+
assert_kind_of ErrorRecoveryNode, node.index
6969
end
7070

7171
def test_interpolated_string_node_parts_xstring
@@ -89,7 +89,7 @@ def test_module_node_constant_path_missing
8989
refute result.success?
9090

9191
node = result.value.statements.body.first.body.body.first
92-
assert_kind_of MissingNode, node.constant_path
92+
assert_kind_of ErrorRecoveryNode, node.constant_path
9393
end
9494

9595
def test_multi_target_node_lefts_back_reference
@@ -185,7 +185,7 @@ def test_pinned_variable_node_variable_missing
185185
refute result.success?
186186

187187
node = result.value.statements.body.first.pattern
188-
assert_kind_of MissingNode, node.variable
188+
assert_kind_of ErrorRecoveryNode, node.variable
189189
end
190190

191191
def test_rescue_node_reference_back_reference
@@ -209,7 +209,7 @@ def test_rescue_node_reference_missing
209209
refute result.success?
210210

211211
node = result.value.statements.body.first.rescue_clause
212-
assert_kind_of MissingNode, node.reference
212+
assert_kind_of ErrorRecoveryNode, node.reference
213213
end
214214
end
215215
end

test/prism/result/source_location_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -920,7 +920,7 @@ def test_YieldNode
920920
end
921921

922922
def test_all_tested
923-
expected = Prism.constants.grep(/.Node$/).sort - %i[MissingNode ProgramNode]
923+
expected = Prism.constants.grep(/.Node$/).sort - %i[ErrorRecoveryNode ProgramNode]
924924
actual = SourceLocationTest.instance_methods(false).grep(/.Node$/).map { |name| name[5..].to_sym }.sort
925925
assert_equal expected, actual
926926
end

0 commit comments

Comments
 (0)