@@ -1701,18 +1701,18 @@ yp_constant_read_node_create(yp_parser_t *parser, const yp_token_t *name) {
1701
1701
1702
1702
// Allocate a new ConstantWriteNode node.
1703
1703
static yp_constant_write_node_t *
1704
- yp_constant_write_node_create(yp_parser_t *parser, yp_constant_read_node_t *target , const yp_token_t *operator, yp_node_t *value) {
1704
+ yp_constant_write_node_create(yp_parser_t *parser, yp_location_t *name_loc , const yp_token_t *operator, yp_node_t *value) {
1705
1705
yp_constant_write_node_t *node = YP_ALLOC_NODE(parser, yp_constant_write_node_t);
1706
1706
1707
1707
*node = (yp_constant_write_node_t) {
1708
1708
{
1709
1709
.type = YP_NODE_CONSTANT_WRITE_NODE,
1710
1710
.location = {
1711
- .start = target->base.location. start,
1712
- .end = value != NULL ? value->location.end : target->base.location. end
1711
+ .start = name_loc-> start,
1712
+ .end = value != NULL ? value->location.end : name_loc-> end
1713
1713
},
1714
1714
},
1715
- .name_loc = YP_LOCATION_NODE_VALUE((yp_node_t *) target) ,
1715
+ .name_loc = *name_loc ,
1716
1716
.operator_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(operator),
1717
1717
.value = value
1718
1718
};
@@ -7582,8 +7582,12 @@ parse_target(yp_parser_t *parser, yp_node_t *target, yp_token_t *operator, yp_no
7582
7582
}
7583
7583
case YP_NODE_CONSTANT_PATH_NODE:
7584
7584
return (yp_node_t *) yp_constant_path_write_node_create(parser, target, operator, value);
7585
- case YP_NODE_CONSTANT_READ_NODE:
7586
- return (yp_node_t *) yp_constant_write_node_create(parser, (yp_constant_read_node_t *) target, operator, value);
7585
+ case YP_NODE_CONSTANT_READ_NODE: {
7586
+ yp_constant_write_node_t *node = yp_constant_write_node_create(parser, &target->location, operator, value);
7587
+ yp_node_destroy(parser, target);
7588
+
7589
+ return (yp_node_t *) node;
7590
+ }
7587
7591
case YP_NODE_BACK_REFERENCE_READ_NODE:
7588
7592
case YP_NODE_NUMBERED_REFERENCE_READ_NODE:
7589
7593
yp_diagnostic_list_append(&parser->error_list, target->location.start, target->location.end, "Can't set variable");
0 commit comments