Repository: ruby/yarp
Pull request #1355 (2023-08-29 17:49:59)

add a location accessor on generic `Node`
This came up when trying to write code against this crate; sometimes you just want the location of a node without caring about the specific kind of node that it is.

The helper is possibly superfluous, but it makes things slightly more readable IMHO.


Patch:
diff --git a/.github/workflows/github-pages.yml b/.github/workflows/github-pages.yml
index 4e7e355f..1b569f4e 100644
--- a/.github/workflows/github-pages.yml
+++ b/.github/workflows/github-pages.yml
@@ -23,7 +23,6 @@ concurrency:
 
 jobs:
   build:
-    if: github.repository == 'ruby/yarp'
     runs-on: ubuntu-latest
     steps:
       - name: Checkout
diff --git a/config.yml b/config.yml
index b4e8b479..d3543608 100644
--- a/config.yml
+++ b/config.yml
@@ -1298,8 +1298,6 @@ nodes:
                   ^^^^^^^^^^^
   - name: InstanceVariableAndWriteNode
     child_nodes:
-      - name: name
-        type: constant
       - name: name_loc
         type: location
       - name: operator_loc
@@ -1313,8 +1311,6 @@ nodes:
           ^^^^^^^^^^^^^^^^^
   - name: InstanceVariableOperatorWriteNode
     child_nodes:
-      - name: name
-        type: constant
       - name: name_loc
         type: location
       - name: operator_loc
@@ -1330,8 +1326,6 @@ nodes:
           ^^^^^^^^^^^^^^^^
   - name: InstanceVariableOrWriteNode
     child_nodes:
-      - name: name
-        type: constant
       - name: name_loc
         type: location
       - name: operator_loc
@@ -1344,18 +1338,12 @@ nodes:
           @target ||= value
           ^^^^^^^^^^^^^^^^^
   - name: InstanceVariableReadNode
-    child_nodes:
-      - name: name
-        type: constant
     comment: |
       Represents referencing an instance variable.
 
           @foo
           ^^^^
   - name: InstanceVariableTargetNode
-    child_nodes:
-      - name: name
-        type: constant
     comment: |
       Represents writing to an instance variable in a context that doesn't have an explicit value.
 
@@ -1363,8 +1351,6 @@ nodes:
           ^^^^  ^^^^
   - name: InstanceVariableWriteNode
     child_nodes:
-      - name: name
-        type: constant
       - name: name_loc
         type: location
       - name: value
diff --git a/lib/yarp/desugar_visitor.rb b/lib/yarp/desugar_visitor.rb
index 83a9bb53..3f901630 100644
--- a/lib/yarp/desugar_visitor.rb
+++ b/lib/yarp/desugar_visitor.rb
@@ -173,8 +173,8 @@ module YARP
     # @foo && @foo = bar
     def visit_instance_variable_and_write_node(node)
       AndNode.new(
-        InstanceVariableReadNode.new(node.name, node.name_loc),
-        InstanceVariableWriteNode.new(node.name, node.name_loc, node.value, node.operator_loc, node.location),
+        InstanceVariableReadNode.new(node.name_loc),
+        InstanceVariableWriteNode.new(node.name_loc, node.value, node.operator_loc, node.location),
         node.operator_loc,
         node.location
       )
@@ -187,8 +187,8 @@ module YARP
     # @foo || @foo = bar
     def visit_instance_variable_or_write_node(node)
       OrNode.new(
-        InstanceVariableReadNode.new(node.name, node.name_loc),
-        InstanceVariableWriteNode.new(node.name, node.name_loc, node.value, node.operator_loc, node.location),
+        InstanceVariableReadNode.new(node.name_loc),
+        InstanceVariableWriteNode.new(node.name_loc, node.value, node.operator_loc, node.location),
         node.operator_loc,
         node.location
       )
@@ -200,7 +200,7 @@ module YARP
     #
     # @foo = @foo + bar
     def visit_instance_variable_operator_write_node(node)
-      desugar_operator_write_node(node, InstanceVariableWriteNode, InstanceVariableReadNode, arguments: [node.name])
+      desugar_operator_write_node(node, InstanceVariableWriteNode, InstanceVariableReadNode)
     end
 
     # foo &&= bar
diff --git a/rust/yarp/build.rs b/rust/yarp/build.rs
index 83ca334e..3e15175f 100644
--- a/rust/yarp/build.rs
+++ b/rust/yarp/build.rs
@@ -675,6 +675,17 @@ impl<'pr> Node<'pr> {{
     writeln!(file, "    }}")?;
     writeln!(file)?;
 
+    writeln!(file, "    /// Returns the location of this node.")?;
+    writeln!(file, "    #[must_use]")?;
+    writeln!(file, "    pub fn location(&self) -> Location<'pr> {{")?;
+    writeln!(file, "        match *self {{")?;
+    for node in &config.nodes {
+        writeln!(file, "            Self::{} {{ pointer, .. }} => Location {{ pointer: unsafe {{ NonNull::new_unchecked(&mut (*pointer.cast::<yp_node_t>()).location) }}, marker: PhantomData }},", node.name)?;
+    }
+    writeln!(file, "        }}")?;
+    writeln!(file, "    }}")?;
+    writeln!(file)?;
+
     for node in &config.nodes {
         writeln!(file, "    /// Returns the node as a `{}`.", node.name)?;
         writeln!(file, "    #[must_use]")?;
diff --git a/rust/yarp/src/lib.rs b/rust/yarp/src/lib.rs
index 6d47eb5a..21059a06 100644
--- a/rust/yarp/src/lib.rs
+++ b/rust/yarp/src/lib.rs
@@ -252,6 +252,11 @@ mod tests {
 
         assert_eq!(slice, "222");
 
+        let location = node.location();
+        let slice = std::str::from_utf8(result.as_slice(&location)).unwrap();
+
+        assert_eq!(slice, "222");
+
         let slice = std::str::from_utf8(location.as_slice()).unwrap();
 
         assert_eq!(slice, "222");
diff --git a/src/yarp.c b/src/yarp.c
index 089de42b..8cd2c200 100644
--- a/src/yarp.c
+++ b/src/yarp.c
@@ -2621,7 +2621,8 @@ yp_in_node_create(yp_parser_t *parser, yp_node_t *pattern, yp_statements_node_t
 
 // Allocate and initialize a new InstanceVariableAndWriteNode node.
 static yp_instance_variable_and_write_node_t *
-yp_instance_variable_and_write_node_create(yp_parser_t *parser, yp_instance_variable_read_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+yp_instance_variable_and_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+    assert(YP_NODE_TYPE_P(target, YP_NODE_INSTANCE_VARIABLE_READ_NODE));
     assert(operator->type == YP_TOKEN_AMPERSAND_AMPERSAND_EQUAL);
     yp_instance_variable_and_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_and_write_node_t);
 
@@ -2629,12 +2630,11 @@ yp_instance_variable_and_write_node_create(yp_parser_t *parser, yp_instance_vari
         {
             .type = YP_NODE_INSTANCE_VARIABLE_AND_WRITE_NODE,
             .location = {
-                .start = target->base.location.start,
+                .start = target->location.start,
                 .end = value->location.end
             }
         },
-        .name = target->name,
-        .name_loc = target->base.location,
+        .name_loc = target->location,
         .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
         .value = value
     };
@@ -2644,19 +2644,18 @@ yp_instance_variable_and_write_node_create(yp_parser_t *parser, yp_instance_vari
 
 // Allocate and initialize a new InstanceVariableOperatorWriteNode node.
 static yp_instance_variable_operator_write_node_t *
-yp_instance_variable_operator_write_node_create(yp_parser_t *parser, yp_instance_variable_read_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+yp_instance_variable_operator_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
     yp_instance_variable_operator_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_operator_write_node_t);
 
     *node = (yp_instance_variable_operator_write_node_t) {
         {
             .type = YP_NODE_INSTANCE_VARIABLE_OPERATOR_WRITE_NODE,
             .location = {
-                .start = target->base.location.start,
+                .start = target->location.start,
                 .end = value->location.end
             }
         },
-        .name = target->name,
-        .name_loc = target->base.location,
+        .name_loc = target->location,
         .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
         .value = value,
         .operator = yp_parser_constant_id_location(parser, operator->start, operator->end - 1)
@@ -2667,7 +2666,8 @@ yp_instance_variable_operator_write_node_create(yp_parser_t *parser, yp_instance
 
 // Allocate and initialize a new InstanceVariableOrWriteNode node.
 static yp_instance_variable_or_write_node_t *
-yp_instance_variable_or_write_node_create(yp_parser_t *parser, yp_instance_variable_read_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+yp_instance_variable_or_write_node_create(yp_parser_t *parser, yp_node_t *target, const yp_token_t *operator, yp_node_t *value) {
+    assert(YP_NODE_TYPE_P(target, YP_NODE_INSTANCE_VARIABLE_READ_NODE));
     assert(operator->type == YP_TOKEN_PIPE_PIPE_EQUAL);
     yp_instance_variable_or_write_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_or_write_node_t);
 
@@ -2675,12 +2675,11 @@ yp_instance_variable_or_write_node_create(yp_parser_t *parser, yp_instance_varia
         {
             .type = YP_NODE_INSTANCE_VARIABLE_OR_WRITE_NODE,
             .location = {
-                .start = target->base.location.start,
+                .start = target->location.start,
                 .end = value->location.end
             }
         },
-        .name = target->name,
-        .name_loc = target->base.location,
+        .name_loc = target->location,
         .operator_loc = YP_LOCATION_TOKEN_VALUE(operator),
         .value = value
     };
@@ -2694,13 +2693,9 @@ yp_instance_variable_read_node_create(yp_parser_t *parser, const yp_token_t *tok
     assert(token->type == YP_TOKEN_INSTANCE_VARIABLE);
     yp_instance_variable_read_node_t *node = YP_ALLOC_NODE(parser, yp_instance_variable_read_node_t);
 
-    *node = (yp_instance_variable_read_node_t) {
-        {
-            .type = YP_NODE_INSTANCE_VARIABLE_READ_NODE,
-            .location = YP_LOCATION_TOKEN_VALUE(token)
-        },
-        .name = yp_parser_constant_id_location(parser, token->start + 1, token->end)
-    };
+    *node = (yp_instance_variable_read_node_t) {{
+            .type = YP_NODE_INSTANCE_VARIABLE_READ_NODE, .location = YP_LOCATION_TOKEN_VALUE(token)
+    }};
 
     return node;
 }
@@ -2717,7 +2712,6 @@ yp_instance_variable_write_node_create(yp_parser_t *parser, yp_instance_variable
                 .end = value->location.end
             }
         },
-        .name = read_node->name,
         .name_loc = YP_LOCATION_NODE_BASE_VALUE(read_node),
         .operator_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(operator),
         .value = value
@@ -9055,12 +9049,10 @@ parse_rescues(yp_parser_t *parser, yp_begin_node_t *parent_node) {
         }
 
         if (!match_any_type_p(parser, 3, YP_TOKEN_KEYWORD_ELSE, YP_TOKEN_KEYWORD_ENSURE, YP_TOKEN_KEYWORD_END)) {
-            yp_accepts_block_stack_push(parser, true);
             yp_statements_node_t *statements = parse_statements(parser, YP_CONTEXT_RESCUE);
             if (statements) {
                 yp_rescue_node_statements_set(rescue, statements);
             }
-            yp_accepts_block_stack_pop(parser);
             accept_any(parser, 2, YP_TOKEN_NEWLINE, YP_TOKEN_SEMICOLON);
         }
 
@@ -9091,9 +9083,7 @@ parse_rescues(yp_parser_t *parser, yp_begin_node_t *parent_node) {
 
         yp_statements_node_t *else_statements = NULL;
         if (!match_any_type_p(parser, 2, YP_TOKEN_KEYWORD_END, YP_TOKEN_KEYWORD_ENSURE)) {
-            yp_accepts_block_stack_push(parser, true);
             else_statements = parse_statements(parser, YP_CONTEXT_RESCUE_ELSE);
-            yp_accepts_block_stack_pop(parser);
             accept_any(parser, 2, YP_TOKEN_NEWLINE, YP_TOKEN_SEMICOLON);
         }
 
@@ -9107,9 +9097,7 @@ parse_rescues(yp_parser_t *parser, yp_begin_node_t *parent_node) {
 
         yp_statements_node_t *ensure_statements = NULL;
         if (!match_type_p(parser, YP_TOKEN_KEYWORD_END)) {
-            yp_accepts_block_stack_push(parser, true);
             ensure_statements = parse_statements(parser, YP_CONTEXT_ENSURE);
-            yp_accepts_block_stack_pop(parser);
             accept_any(parser, 2, YP_TOKEN_NEWLINE, YP_TOKEN_SEMICOLON);
         }
 
@@ -9219,9 +9207,7 @@ parse_block(yp_parser_t *parser) {
     } else {
         if (!match_type_p(parser, YP_TOKEN_KEYWORD_END)) {
             if (!match_any_type_p(parser, 3, YP_TOKEN_KEYWORD_RESCUE, YP_TOKEN_KEYWORD_ELSE, YP_TOKEN_KEYWORD_ENSURE)) {
-                yp_accepts_block_stack_push(parser, true);
                 statements = (yp_node_t *) parse_statements(parser, YP_CONTEXT_BLOCK_KEYWORDS);
-                yp_accepts_block_stack_pop(parser);
             }
 
             if (match_any_type_p(parser, 2, YP_TOKEN_KEYWORD_RESCUE, YP_TOKEN_KEYWORD_ENSURE)) {
@@ -11382,9 +11368,7 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
 
                 yp_node_t *statements = NULL;
                 if (!match_any_type_p(parser, 3, YP_TOKEN_KEYWORD_RESCUE, YP_TOKEN_KEYWORD_ENSURE, YP_TOKEN_KEYWORD_END)) {
-                    yp_accepts_block_stack_push(parser, true);
                     statements = (yp_node_t *) parse_statements(parser, YP_CONTEXT_SCLASS);
-                    yp_accepts_block_stack_pop(parser);
                 }
 
                 if (match_any_type_p(parser, 2, YP_TOKEN_KEYWORD_RESCUE, YP_TOKEN_KEYWORD_ENSURE)) {
@@ -11665,9 +11649,7 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
                 yp_do_loop_stack_push(parser, false);
 
                 if (!match_any_type_p(parser, 3, YP_TOKEN_KEYWORD_RESCUE, YP_TOKEN_KEYWORD_ENSURE, YP_TOKEN_KEYWORD_END)) {
-                    yp_accepts_block_stack_push(parser, true);
                     statements = (yp_node_t *) parse_statements(parser, YP_CONTEXT_DEF);
-                    yp_accepts_block_stack_pop(parser);
                 }
 
                 if (match_any_type_p(parser, 2, YP_TOKEN_KEYWORD_RESCUE, YP_TOKEN_KEYWORD_ENSURE)) {
@@ -12524,9 +12506,7 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
                 opening = parser->previous;
 
                 if (!match_any_type_p(parser, 3, YP_TOKEN_KEYWORD_END, YP_TOKEN_KEYWORD_RESCUE, YP_TOKEN_KEYWORD_ENSURE)) {
-                    yp_accepts_block_stack_push(parser, true);
                     body = (yp_node_t *) parse_statements(parser, YP_CONTEXT_LAMBDA_DO_END);
-                    yp_accepts_block_stack_pop(parser);
                 }
 
                 if (match_any_type_p(parser, 2, YP_TOKEN_KEYWORD_RESCUE, YP_TOKEN_KEYWORD_ENSURE)) {
@@ -12827,7 +12807,7 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
                     parser_lex(parser);
 
                     yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after &&=");
-                    yp_node_t *result = (yp_node_t *) yp_instance_variable_and_write_node_create(parser, (yp_instance_variable_read_node_t *) node, &token, value);
+                    yp_node_t *result = (yp_node_t *) yp_instance_variable_and_write_node_create(parser, node, &token, value);
 
                     yp_node_destroy(parser, node);
                     return result;
@@ -12928,7 +12908,7 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
                     parser_lex(parser);
 
                     yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after ||=");
-                    yp_node_t *result = (yp_node_t *) yp_instance_variable_or_write_node_create(parser, (yp_instance_variable_read_node_t *) node, &token, value);
+                    yp_node_t *result = (yp_node_t *) yp_instance_variable_or_write_node_create(parser, node, &token, value);
 
                     yp_node_destroy(parser, node);
                     return result;
@@ -13039,7 +13019,7 @@ parse_expression_infix(yp_parser_t *parser, yp_node_t *node, yp_binding_power_t
                     parser_lex(parser);
 
                     yp_node_t *value = parse_expression(parser, binding_power, "Expected a value after the operator.");
-                    yp_node_t *result = (yp_node_t *) yp_instance_variable_operator_write_node_create(parser, (yp_instance_variable_read_node_t *) node, &token, value);
+                    yp_node_t *result = (yp_node_t *) yp_instance_variable_operator_write_node_create(parser, node, &token, value);
 
                     yp_node_destroy(parser, node);
                     return result;


Test patch:
diff --git a/test/yarp/fixtures/begin_ensure.txt b/test/yarp/fixtures/begin_ensure.txt
index 6cfb6274..1c6f9dac 100644
--- a/test/yarp/fixtures/begin_ensure.txt
+++ b/test/yarp/fixtures/begin_ensure.txt
@@ -12,10 +12,3 @@ begin a
 
 begin a; ensure b; end
 
-begin begin:s.l begin ensure Module.new do
-  begin
-    break
-    ensure Module.new do
-    end
-  end
-end end end end
diff --git a/test/yarp/snapshots/begin_ensure.txt b/test/yarp/snapshots/begin_ensure.txt
index 8e987312..e04a1236 100644
--- a/test/yarp/snapshots/begin_ensure.txt
+++ b/test/yarp/snapshots/begin_ensure.txt
@@ -1,6 +1,6 @@
-ProgramNode(0...211)(
+ProgramNode(0...94)(
   [],
-  StatementsNode(0...211)(
+  StatementsNode(0...94)(
     [BeginNode(0...20)(
        (0...5),
        StatementsNode(6...7)(
@@ -64,99 +64,6 @@ ProgramNode(0...211)(
          (91...94)
        ),
        (91...94)
-     ),
-     BeginNode(96...211)(
-       (96...101),
-       StatementsNode(102...207)(
-         [BeginNode(102...207)(
-            (102...107),
-            StatementsNode(107...203)(
-              [CallNode(107...203)(
-                 SymbolNode(107...109)((107...108), (108...109), nil, "s"),
-                 (109...110),
-                 (110...111),
-                 nil,
-                 ArgumentsNode(112...203)(
-                   [BeginNode(112...203)(
-                      (112...117),
-                      nil,
-                      nil,
-                      nil,
-                      EnsureNode(118...203)(
-                        (118...124),
-                        StatementsNode(125...199)(
-                          [CallNode(125...199)(
-                             ConstantReadNode(125...131)(),
-                             (131...132),
-                             (132...135),
-                             nil,
-                             nil,
-                             nil,
-                             BlockNode(136...199)(
-                               [],
-                               nil,
-                               StatementsNode(141...195)(
-                                 [BeginNode(141...195)(
-                                    (141...146),
-                                    StatementsNode(151...156)(
-                                      [BreakNode(151...156)(nil, (151...156))]
-                                    ),
-                                    nil,
-                                    nil,
-                                    EnsureNode(161...195)(
-                                      (161...167),
-                                      StatementsNode(168...189)(
-                                        [CallNode(168...189)(
-                                           ConstantReadNode(168...174)(),
-                                           (174...175),
-                                           (175...178),
-                                           nil,
-                                           nil,
-                                           nil,
-                                           BlockNode(179...189)(
-                                             [],
-                                             nil,
-                                             nil,
-                                             (179...181),
-                                             (186...189)
-                                           ),
-                                           0,
-                                           "new"
-                                         )]
-                                      ),
-                                      (192...195)
-                                    ),
-                                    (192...195)
-                                  )]
-                               ),
-                               (136...138),
-                               (196...199)
-                             ),
-                             0,
-                             "new"
-                           )]
-                        ),
-                        (200...203)
-                      ),
-                      (200...203)
-                    )]
-                 ),
-                 nil,
-                 nil,
-                 0,
-                 "l"
-               )]
-            ),
-            nil,
-            nil,
-            nil,
-            (204...207)
-          )]
-       ),
-       nil,
-       nil,
-       nil,
-       (208...211)
      )]
   )
 )
diff --git a/test/yarp/snapshots/methods.txt b/test/yarp/snapshots/methods.txt
index 32a7a4e7..a2cfa8e0 100644
--- a/test/yarp/snapshots/methods.txt
+++ b/test/yarp/snapshots/methods.txt
@@ -199,7 +199,7 @@ ProgramNode(0...1194)(
      ),
      DefNode(190...204)(
        (199...200),
-       InstanceVariableReadNode(194...198)(:var),
+       InstanceVariableReadNode(194...198)(),
        nil,
        nil,
        [],
diff --git a/test/yarp/snapshots/patterns.txt b/test/yarp/snapshots/patterns.txt
index f888d149..de5946a7 100644
--- a/test/yarp/snapshots/patterns.txt
+++ b/test/yarp/snapshots/patterns.txt
@@ -923,7 +923,7 @@ ProgramNode(0...3743)(
          "foo"
        ),
        PinnedVariableNode(961...966)(
-         InstanceVariableReadNode(962...966)(:bar),
+         InstanceVariableReadNode(962...966)(),
          (961...962)
        ),
        (958...960)
diff --git a/test/yarp/snapshots/seattlerb/case_in.txt b/test/yarp/snapshots/seattlerb/case_in.txt
index 5ea3d11b..8a5fafdf 100644
--- a/test/yarp/snapshots/seattlerb/case_in.txt
+++ b/test/yarp/snapshots/seattlerb/case_in.txt
@@ -494,7 +494,7 @@ ProgramNode(0...747)(
           ArrayPatternNode(627...643)(
             nil,
             [PinnedVariableNode(628...631)(
-               InstanceVariableReadNode(629...631)(:a),
+               InstanceVariableReadNode(629...631)(),
                (628...629)
              ),
              PinnedVariableNode(633...636)(
diff --git a/test/yarp/snapshots/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes.txt b/test/yarp/snapshots/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes.txt
index 5aab2888..cfb1f964 100644
--- a/test/yarp/snapshots/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes.txt
+++ b/test/yarp/snapshots/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes.txt
@@ -6,7 +6,7 @@ ProgramNode(0...5)(
        [StringNode(6...11)(nil, (6...11), nil, "foo\r"),
         EmbeddedVariableNode(11...16)(
           (11...12),
-          InstanceVariableReadNode(12...16)(:bar)
+          InstanceVariableReadNode(12...16)()
         ),
         StringNode(16...17)(nil, (16...17), nil, "\n")],
        (17...21)
diff --git a/test/yarp/snapshots/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes_windows.txt b/test/yarp/snapshots/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes_windows.txt
index 04727011..ee013f51 100644
--- a/test/yarp/snapshots/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes_windows.txt
+++ b/test/yarp/snapshots/seattlerb/heredoc_with_interpolation_and_carriage_return_escapes_windows.txt
@@ -6,7 +6,7 @@ ProgramNode(0...5)(
        [StringNode(7...12)(nil, (7...12), nil, "foo\r"),
         EmbeddedVariableNode(12...17)(
           (12...13),
-          InstanceVariableReadNode(13...17)(:bar)
+          InstanceVariableReadNode(13...17)()
         ),
         StringNode(17...19)(nil, (17...19), nil, "\r\n")],
        (19...24)
diff --git a/test/yarp/snapshots/seattlerb/lasgn_ivar_env.txt b/test/yarp/snapshots/seattlerb/lasgn_ivar_env.txt
index f065032f..b71eeaf2 100644
--- a/test/yarp/snapshots/seattlerb/lasgn_ivar_env.txt
+++ b/test/yarp/snapshots/seattlerb/lasgn_ivar_env.txt
@@ -1,11 +1,6 @@
 ProgramNode(0...7)(
   [],
   StatementsNode(0...7)(
-    [InstanceVariableWriteNode(0...7)(
-       :a,
-       (0...2),
-       IntegerNode(5...7)(),
-       (3...4)
-     )]
+    [InstanceVariableWriteNode(0...7)((0...2), IntegerNode(5...7)(), (3...4))]
   )
 )
diff --git a/test/yarp/snapshots/seattlerb/parse_line_call_ivar_arg_no_parens_line_break.txt b/test/yarp/snapshots/seattlerb/parse_line_call_ivar_arg_no_parens_line_break.txt
index efbc413f..b7cca173 100644
--- a/test/yarp/snapshots/seattlerb/parse_line_call_ivar_arg_no_parens_line_break.txt
+++ b/test/yarp/snapshots/seattlerb/parse_line_call_ivar_arg_no_parens_line_break.txt
@@ -6,7 +6,7 @@ ProgramNode(0...4)(
        nil,
        (0...1),
        nil,
-       ArgumentsNode(2...4)([InstanceVariableReadNode(2...4)(:b)]),
+       ArgumentsNode(2...4)([InstanceVariableReadNode(2...4)()]),
        nil,
        nil,
        0,
diff --git a/test/yarp/snapshots/seattlerb/parse_line_call_ivar_line_break_paren.txt b/test/yarp/snapshots/seattlerb/parse_line_call_ivar_line_break_paren.txt
index 6466d9dd..ae67416e 100644
--- a/test/yarp/snapshots/seattlerb/parse_line_call_ivar_line_break_paren.txt
+++ b/test/yarp/snapshots/seattlerb/parse_line_call_ivar_line_break_paren.txt
@@ -6,7 +6,7 @@ ProgramNode(0...6)(
        nil,
        (0...1),
        (1...2),
-       ArgumentsNode(2...4)([InstanceVariableReadNode(2...4)(:b)]),
+       ArgumentsNode(2...4)([InstanceVariableReadNode(2...4)()]),
        (5...6),
        nil,
        0,
diff --git a/test/yarp/snapshots/strings.txt b/test/yarp/snapshots/strings.txt
index d6f62462..38033453 100644
--- a/test/yarp/snapshots/strings.txt
+++ b/test/yarp/snapshots/strings.txt
@@ -185,7 +185,7 @@ ProgramNode(0...498)(
        (414...415),
        [EmbeddedVariableNode(415...420)(
           (415...416),
-          InstanceVariableReadNode(416...420)(:foo)
+          InstanceVariableReadNode(416...420)()
         )],
        (420...421)
      ),
diff --git a/test/yarp/snapshots/unparser/corpus/literal/assignment.txt b/test/yarp/snapshots/unparser/corpus/literal/assignment.txt
index 6166e0cd..bcf85388 100644
--- a/test/yarp/snapshots/unparser/corpus/literal/assignment.txt
+++ b/test/yarp/snapshots/unparser/corpus/literal/assignment.txt
@@ -66,8 +66,8 @@ ProgramNode(0...704)(
        (74...75)
      ),
      MultiWriteNode(85...102)(
-       [InstanceVariableTargetNode(86...88)(:a),
-        InstanceVariableTargetNode(90...92)(:b)],
+       [InstanceVariableTargetNode(86...88)(),
+        InstanceVariableTargetNode(90...92)()],
        (94...95),
        ArrayNode(96...102)(
          [IntegerNode(97...98)(), IntegerNode(100...101)()],
@@ -296,7 +296,6 @@ ProgramNode(0...704)(
        (306...307)
      ),
      InstanceVariableWriteNode(310...316)(
-       :a,
        (310...312),
        IntegerNode(315...316)(),
        (313...314)
@@ -606,7 +605,6 @@ ProgramNode(0...704)(
        (543...546)
      ),
      InstanceVariableOrWriteNode(551...561)(
-       :a,
        (551...553),
        (554...557),
        StringNode(558...561)((558...560), (560...560), (560...561), "")
@@ -700,7 +698,6 @@ ProgramNode(0...704)(
        (665...668)
      ),
      InstanceVariableOrWriteNode(687...704)(
-       :a,
        (687...689),
        (690...693),
        InterpolatedStringNode(694...704)(
diff --git a/test/yarp/snapshots/unparser/corpus/literal/defined.txt b/test/yarp/snapshots/unparser/corpus/literal/defined.txt
index 1d39c45c..c2d6a71b 100644
--- a/test/yarp/snapshots/unparser/corpus/literal/defined.txt
+++ b/test/yarp/snapshots/unparser/corpus/literal/defined.txt
@@ -3,7 +3,7 @@ ProgramNode(0...56)(
   StatementsNode(0...56)(
     [DefinedNode(0...14)(
        (8...9),
-       InstanceVariableReadNode(9...13)(:foo),
+       InstanceVariableReadNode(9...13)(),
        (13...14),
        (0...8)
      ),
diff --git a/test/yarp/snapshots/unparser/corpus/literal/dstr.txt b/test/yarp/snapshots/unparser/corpus/literal/dstr.txt
index 49d08824..84661493 100644
--- a/test/yarp/snapshots/unparser/corpus/literal/dstr.txt
+++ b/test/yarp/snapshots/unparser/corpus/literal/dstr.txt
@@ -75,7 +75,7 @@ ProgramNode(0...299)(
        [StringNode(160...161)(nil, (160...161), nil, "a"),
         EmbeddedVariableNode(161...164)(
           (161...162),
-          InstanceVariableReadNode(162...164)(:a)
+          InstanceVariableReadNode(162...164)()
         )],
        (164...165)
      ),
diff --git a/test/yarp/snapshots/unparser/corpus/literal/literal.txt b/test/yarp/snapshots/unparser/corpus/literal/literal.txt
index a38a7f4f..bc9f8684 100644
--- a/test/yarp/snapshots/unparser/corpus/literal/literal.txt
+++ b/test/yarp/snapshots/unparser/corpus/literal/literal.txt
@@ -153,7 +153,7 @@ ProgramNode(0...916)(
        (206...207),
        [EmbeddedVariableNode(207...210)(
           (207...208),
-          InstanceVariableReadNode(208...210)(:a)
+          InstanceVariableReadNode(208...210)()
         ),
         StringNode(210...211)(nil, (210...211), nil, " "),
         EmbeddedVariableNode(211...215)(
@@ -267,9 +267,7 @@ ProgramNode(0...916)(
        [StringNode(419...422)(nil, (419...422), nil, "foo"),
         EmbeddedStatementsNode(422...429)(
           (422...424),
-          StatementsNode(424...428)(
-            [InstanceVariableReadNode(424...428)(:bar)]
-          ),
+          StatementsNode(424...428)([InstanceVariableReadNode(424...428)()]),
           (428...429)
         )],
        (429...430)
@@ -302,9 +300,7 @@ ProgramNode(0...916)(
        [StringNode(516...519)(nil, (516...519), nil, "foo"),
         EmbeddedStatementsNode(519...526)(
           (519...521),
-          StatementsNode(521...525)(
-            [InstanceVariableReadNode(521...525)(:bar)]
-          ),
+          StatementsNode(521...525)([InstanceVariableReadNode(521...525)()]),
           (525...526)
         )],
        (526...527),
@@ -315,9 +311,7 @@ ProgramNode(0...916)(
        [StringNode(529...532)(nil, (529...532), nil, "foo"),
         EmbeddedStatementsNode(532...539)(
           (532...534),
-          StatementsNode(534...538)(
-            [InstanceVariableReadNode(534...538)(:bar)]
-          ),
+          StatementsNode(534...538)([InstanceVariableReadNode(534...538)()]),
           (538...539)
         )],
        (539...543),
@@ -507,7 +501,7 @@ ProgramNode(0...916)(
        [IntegerNode(693...694)(),
         SplatNode(696...701)(
           (696...697),
-          InstanceVariableReadNode(697...701)(:foo)
+          InstanceVariableReadNode(697...701)()
         )],
        (692...693),
        (701...702)
@@ -515,7 +509,7 @@ ProgramNode(0...916)(
      ArrayNode(703...713)(
        [SplatNode(704...709)(
           (704...705),
-          InstanceVariableReadNode(705...709)(:foo)
+          InstanceVariableReadNode(705...709)()
         ),
         IntegerNode(711...712)()],
        (703...704),
@@ -524,11 +518,11 @@ ProgramNode(0...916)(
      ArrayNode(714...728)(
        [SplatNode(715...720)(
           (715...716),
-          InstanceVariableReadNode(716...720)(:foo)
+          InstanceVariableReadNode(716...720)()
         ),
         SplatNode(722...727)(
           (722...723),
-          InstanceVariableReadNode(723...727)(:baz)
+          InstanceVariableReadNode(723...727)()
         )],
        (714...715),
        (727...728)
diff --git a/test/yarp/snapshots/unparser/corpus/literal/variables.txt b/test/yarp/snapshots/unparser/corpus/literal/variables.txt
index 29857ec5..b7ab14e3 100644
--- a/test/yarp/snapshots/unparser/corpus/literal/variables.txt
+++ b/test/yarp/snapshots/unparser/corpus/literal/variables.txt
@@ -2,7 +2,7 @@ ProgramNode(0...66)(
   [],
   StatementsNode(0...66)(
     [CallNode(0...1)(nil, nil, (0...1), nil, nil, nil, nil, 2, "a"),
-     InstanceVariableReadNode(2...4)(:a),
+     InstanceVariableReadNode(2...4)(),
      ClassVariableReadNode(5...8)(),
      GlobalVariableReadNode(9...11)(),
      NumberedReferenceReadNode(12...14)(),
diff --git a/test/yarp/snapshots/unparser/corpus/semantic/dstr.txt b/test/yarp/snapshots/unparser/corpus/semantic/dstr.txt
index 490b13e0..14843a83 100644
--- a/test/yarp/snapshots/unparser/corpus/semantic/dstr.txt
+++ b/test/yarp/snapshots/unparser/corpus/semantic/dstr.txt
@@ -207,9 +207,7 @@ ProgramNode(0...608)(
          [StringNode(563...564)(nil, (563...564), nil, "a"),
           EmbeddedStatementsNode(564...569)(
             (564...566),
-            StatementsNode(566...568)(
-              [InstanceVariableReadNode(566...568)(:a)]
-            ),
+            StatementsNode(566...568)([InstanceVariableReadNode(566...568)()]),
             (568...569)
           )],
          (569...570)
@@ -222,7 +220,7 @@ ProgramNode(0...608)(
          [StringNode(576...577)(nil, (576...577), nil, "a"),
           EmbeddedVariableNode(577...580)(
             (577...578),
-            InstanceVariableReadNode(578...580)(:a)
+            InstanceVariableReadNode(578...580)()
           )],
          (580...581)
        ),
diff --git a/test/yarp/snapshots/unparser/corpus/semantic/literal.txt b/test/yarp/snapshots/unparser/corpus/semantic/literal.txt
index b9df7fcb..d8578058 100644
--- a/test/yarp/snapshots/unparser/corpus/semantic/literal.txt
+++ b/test/yarp/snapshots/unparser/corpus/semantic/literal.txt
@@ -15,7 +15,7 @@ ProgramNode(0...131)(
        (71...74),
        [EmbeddedStatementsNode(74...81)(
           (74...76),
-          StatementsNode(76...80)([InstanceVariableReadNode(76...80)(:bar)]),
+          StatementsNode(76...80)([InstanceVariableReadNode(76...80)()]),
           (80...81)
         ),
         StringNode(81...84)(nil, (81...84), nil, "baz")],
diff --git a/test/yarp/snapshots/variables.txt b/test/yarp/snapshots/variables.txt
index a6b6a444..35b90dba 100644
--- a/test/yarp/snapshots/variables.txt
+++ b/test/yarp/snapshots/variables.txt
@@ -30,9 +30,8 @@ ProgramNode(0...293)(
        IntegerNode(57...58)()
      ),
      GlobalVariableReadNode(60...64)(),
-     InstanceVariableReadNode(66...70)(:abc),
+     InstanceVariableReadNode(66...70)(),
      InstanceVariableWriteNode(72...80)(
-       :abc,
        (72...76),
        IntegerNode(79...80)(),
        (77...78)
@@ -63,15 +62,14 @@ ProgramNode(0...293)(
        )
      ),
      MultiWriteNode(123...137)(
-       [InstanceVariableTargetNode(123...127)(:foo),
-        InstanceVariableTargetNode(129...133)(:bar)],
+       [InstanceVariableTargetNode(123...127)(),
+        InstanceVariableTargetNode(129...133)()],
        (134...135),
        IntegerNode(136...137)(),
        nil,
        nil
      ),
      InstanceVariableWriteNode(139...150)(
-       :foo,
        (139...143),
        ArrayNode(146...150)(
          [IntegerNode(146...147)(), IntegerNode(149...150)()],
diff --git a/test/yarp/snapshots/whitequark/array_words_interp.txt b/test/yarp/snapshots/whitequark/array_words_interp.txt
index 963a83dd..3cc21323 100644
--- a/test/yarp/snapshots/whitequark/array_words_interp.txt
+++ b/test/yarp/snapshots/whitequark/array_words_interp.txt
@@ -51,7 +51,7 @@ ProgramNode(0...38)(
            StringNode(29...32)(nil, (29...32), nil, "foo"),
            EmbeddedVariableNode(32...37)(
              (32...33),
-             InstanceVariableReadNode(33...37)(:baz)
+             InstanceVariableReadNode(33...37)()
            )],
           nil
         )],
diff --git a/test/yarp/snapshots/whitequark/defined.txt b/test/yarp/snapshots/whitequark/defined.txt
index 9d8d997e..12a30055 100644
--- a/test/yarp/snapshots/whitequark/defined.txt
+++ b/test/yarp/snapshots/whitequark/defined.txt
@@ -3,7 +3,7 @@ ProgramNode(0...42)(
   StatementsNode(0...42)(
     [DefinedNode(0...13)(
        nil,
-       InstanceVariableReadNode(9...13)(:foo),
+       InstanceVariableReadNode(9...13)(),
        nil,
        (0...8)
      ),
diff --git a/test/yarp/snapshots/whitequark/ivar.txt b/test/yarp/snapshots/whitequark/ivar.txt
index cf233251..88bb2ace 100644
--- a/test/yarp/snapshots/whitequark/ivar.txt
+++ b/test/yarp/snapshots/whitequark/ivar.txt
@@ -1,4 +1,4 @@
 ProgramNode(0...4)(
   [],
-  StatementsNode(0...4)([InstanceVariableReadNode(0...4)(:foo)])
+  StatementsNode(0...4)([InstanceVariableReadNode(0...4)()])
 )
diff --git a/test/yarp/snapshots/whitequark/ivasgn.txt b/test/yarp/snapshots/whitequark/ivasgn.txt
index 587dcfaa..4f6f90bb 100644
--- a/test/yarp/snapshots/whitequark/ivasgn.txt
+++ b/test/yarp/snapshots/whitequark/ivasgn.txt
@@ -1,11 +1,6 @@
 ProgramNode(0...9)(
   [],
   StatementsNode(0...9)(
-    [InstanceVariableWriteNode(0...9)(
-       :var,
-       (0...4),
-       IntegerNode(7...9)(),
-       (5...6)
-     )]
+    [InstanceVariableWriteNode(0...9)((0...4), IntegerNode(7...9)(), (5...6))]
   )
 )
diff --git a/test/yarp/snapshots/whitequark/masgn_splat.txt b/test/yarp/snapshots/whitequark/masgn_splat.txt
index c6265c65..e10e6d22 100644
--- a/test/yarp/snapshots/whitequark/masgn_splat.txt
+++ b/test/yarp/snapshots/whitequark/masgn_splat.txt
@@ -51,7 +51,7 @@ ProgramNode(0...139)(
        nil
      ),
      MultiWriteNode(47...65)(
-       [InstanceVariableTargetNode(47...51)(:foo),
+       [InstanceVariableTargetNode(47...51)(),
         ClassVariableTargetNode(53...58)()],
        (59...60),
        ArrayNode(61...65)(
diff --git a/test/yarp/snapshots/whitequark/parser_bug_272.txt b/test/yarp/snapshots/whitequark/parser_bug_272.txt
index 50d75398..eeb981d6 100644
--- a/test/yarp/snapshots/whitequark/parser_bug_272.txt
+++ b/test/yarp/snapshots/whitequark/parser_bug_272.txt
@@ -6,7 +6,7 @@ ProgramNode(0...15)(
        nil,
        (0...1),
        nil,
-       ArgumentsNode(2...4)([InstanceVariableReadNode(2...4)(:b)]),
+       ArgumentsNode(2...4)([InstanceVariableReadNode(2...4)()]),
        nil,
        BlockNode(5...15)(
          [:c],
diff --git a/test/yarp/snapshots/whitequark/resbody_var.txt b/test/yarp/snapshots/whitequark/resbody_var.txt
index 4530e6cd..861a91f7 100644
--- a/test/yarp/snapshots/whitequark/resbody_var.txt
+++ b/test/yarp/snapshots/whitequark/resbody_var.txt
@@ -10,7 +10,7 @@ ProgramNode(0...73)(
          (13...19),
          [],
          (20...22),
-         InstanceVariableTargetNode(23...26)(:ex),
+         InstanceVariableTargetNode(23...26)(),
          StatementsNode(28...31)(
            [CallNode(28...31)(
               nil,
diff --git a/test/yarp/snapshots/whitequark/string_concat.txt b/test/yarp/snapshots/whitequark/string_concat.txt
index fde498b3..c20f4ac3 100644
--- a/test/yarp/snapshots/whitequark/string_concat.txt
+++ b/test/yarp/snapshots/whitequark/string_concat.txt
@@ -7,7 +7,7 @@ ProgramNode(0...14)(
          [StringNode(1...4)(nil, (1...4), nil, "foo"),
           EmbeddedVariableNode(4...7)(
             (4...5),
-            InstanceVariableReadNode(5...7)(:a)
+            InstanceVariableReadNode(5...7)()
           )],
          (7...8)
        ),
diff --git a/test/yarp/snapshots/whitequark/string_dvar.txt b/test/yarp/snapshots/whitequark/string_dvar.txt
index 2378e8fd..c89e3595 100644
--- a/test/yarp/snapshots/whitequark/string_dvar.txt
+++ b/test/yarp/snapshots/whitequark/string_dvar.txt
@@ -5,7 +5,7 @@ ProgramNode(0...14)(
        (0...1),
        [EmbeddedVariableNode(1...4)(
           (1...2),
-          InstanceVariableReadNode(2...4)(:a)
+          InstanceVariableReadNode(2...4)()
         ),
         StringNode(4...5)(nil, (4...5), nil, " "),
         EmbeddedVariableNode(5...9)((5...6), ClassVariableReadNode(6...9)()),
diff --git a/test/yarp/snapshots/whitequark/var_op_asgn.txt b/test/yarp/snapshots/whitequark/var_op_asgn.txt
index 3aff7a6a..4591e68c 100644
--- a/test/yarp/snapshots/whitequark/var_op_asgn.txt
+++ b/test/yarp/snapshots/whitequark/var_op_asgn.txt
@@ -8,7 +8,6 @@ ProgramNode(0...53)(
        :|
      ),
      InstanceVariableOperatorWriteNode(13...20)(
-       :a,
        (13...15),
        (16...18),
        IntegerNode(19...20)(),