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 };