Skip to content

Commit 8a14cdc

Browse files
Validate ClassNode
1 parent 9f8334e commit 8a14cdc

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1865,7 +1865,7 @@ nodes:
18651865
kind:
18661866
- ConstantReadNode
18671867
- ConstantPathNode
1868-
- on error: CallNode # class 0.X end
1868+
- on error: ErrorRecoveryNode
18691869
- name: inheritance_operator_loc
18701870
type: location?
18711871
comment: |

src/prism.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18694,7 +18694,8 @@ parse_expression_prefix(pm_parser_t *parser, pm_binding_power_t binding_power, b
1869418694
pm_parser_scope_pop(parser);
1869518695
pm_do_loop_stack_pop(parser);
1869618696

18697-
if (!PM_NODE_TYPE_P(constant_path, PM_CONSTANT_PATH_NODE) && !(PM_NODE_TYPE_P(constant_path, PM_CONSTANT_READ_NODE))) {
18697+
PM_VALIDATE_NODE_TYPE(parser, constant_path, PM_CONSTANT_PATH_NODE, PM_CONSTANT_READ_NODE);
18698+
if (PM_NODE_TYPE_P(constant_path, PM_ERROR_RECOVERY_NODE)) {
1869818699
pm_parser_err_node(parser, constant_path, PM_ERR_CLASS_NAME);
1869918700
}
1870018701

test/prism/result/error_recovery_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def test_class_node_constant_path_call
4545
refute result.success?
4646

4747
node = result.value.statements.body.first
48-
assert_kind_of CallNode, node.constant_path
48+
assert_kind_of ErrorRecoveryNode, node.constant_path
49+
assert_kind_of CallNode, node.constant_path.child
4950
end
5051

5152
def test_for_node_index_back_reference

0 commit comments

Comments
 (0)