summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthew healy <matthew-healy@users.noreply.github.com>2024-03-11 20:45:54 +0100
committergit <svn-admin@ruby-lang.org>2024-03-11 19:45:58 +0000
commite407e3f497eaefb15311833c274b83ded5d17e21 (patch)
treeaa2682148148868c82c6e94ad0ada2c1caa2c6fb
parenta6dac9bb4f05530aec8c3f117d2cbe38bade99f2 (diff)
[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 <kddnewton@gmail.com>
-rw-r--r--prism/config.yml27
-rw-r--r--prism/prism.c2
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
};