From e407e3f497eaefb15311833c274b83ded5d17e21 Mon Sep 17 00:00:00 2001 From: matthew healy Date: Mon, 11 Mar 2024 20:45:54 +0100 Subject: [PATCH] [ruby/prism] Document `ClassVariableWriteNode` fields (https://github.com/ruby/prism/pull/2162) * Make ClassVariableWriteNode operator_loc non-nullable * Document ClassVariableWriteNode fields * Update config.yml --------- https://github.com/ruby/prism/commit/659b133888 Co-authored-by: Kevin Newton --- prism/config.yml | 27 ++++++++++++++++++++++++++- prism/prism.c | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/prism/config.yml b/prism/config.yml index 08d4f78c47..d6698ab1b7 100644 --- a/prism/config.yml +++ b/prism/config.yml @@ -1302,12 +1302,37 @@ nodes: fields: - name: name type: constant + comment: | + The name of the class variable, which is a `@@` followed by an [identifier](https://github.com/ruby/prism/blob/main/docs/parsing_rules.md#identifiers). + + @@abc = 123 # name `@@abc` + + @@_test = :test # name `@@_test` - name: name_loc type: location + comment: | + The location of the variable name. + + @@foo = :bar + ^^^^^ - name: value type: node + comment: | + The value to assign to the class variable. Can be any node that + represents a non-void expression. + + @@foo = :bar + ^^^^ + + @@_xyz = 123 + ^^^ - name: operator_loc - type: location? + type: location + comment: | + The location of the `=` operator. + + @@foo = :bar + ^ comment: | Represents writing to a class variable. diff --git a/prism/prism.c b/prism/prism.c index b0c061a432..98c18407b8 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -2691,7 +2691,7 @@ pm_class_variable_write_node_create(pm_parser_t *parser, pm_class_variable_read_ }, .name = read_node->name, .name_loc = PM_LOCATION_NODE_VALUE((pm_node_t *) read_node), - .operator_loc = PM_OPTIONAL_LOCATION_TOKEN_VALUE(operator), + .operator_loc = PM_LOCATION_TOKEN_VALUE(operator), .value = value };