Repository: ruby/yarp
Pull request #1330 (2023-08-25 17:33:01)

Allow whitespace after "(en)coding" before ":", as in "encoding    :"


Patch:
diff --git a/config.yml b/config.yml
index 3662c176..e4987013 100644
--- a/config.yml
+++ b/config.yml
@@ -731,8 +731,6 @@ nodes:
         type: node?
       - name: end_keyword_loc
         type: location
-      - name: name
-        type: string
     comment: |
       Represents a class declaration involving the `class` keyword.
 
@@ -1320,8 +1318,6 @@ nodes:
         type: node?
       - name: end_keyword_loc
         type: location
-      - name: name
-        type: string
     comment: |
       Represents a module declaration involving the `module` keyword.
 
diff --git a/src/yarp.c b/src/yarp.c
index 3ec2b1d2..73adac63 100644
--- a/src/yarp.c
+++ b/src/yarp.c
@@ -1553,7 +1553,7 @@ yp_case_node_end_keyword_loc_set(yp_case_node_t *node, const yp_token_t *end_key
 
 // Allocate a new ClassNode node.
 static yp_class_node_t *
-yp_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *class_keyword, yp_node_t *constant_path, const yp_token_t *name, const yp_token_t *inheritance_operator, yp_node_t *superclass, yp_node_t *body, const yp_token_t *end_keyword) {
+yp_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *class_keyword, yp_node_t *constant_path, const yp_token_t *inheritance_operator, yp_node_t *superclass, yp_node_t *body, const yp_token_t *end_keyword) {
     yp_class_node_t *node = YP_ALLOC_NODE(parser, yp_class_node_t);
 
     *node = (yp_class_node_t) {
@@ -1567,11 +1567,9 @@ yp_class_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const y
         .inheritance_operator_loc = YP_OPTIONAL_LOCATION_TOKEN_VALUE(inheritance_operator),
         .superclass = superclass,
         .body = body,
-        .end_keyword_loc = YP_LOCATION_TOKEN_VALUE(end_keyword),
-        .name = YP_EMPTY_STRING
+        .end_keyword_loc = YP_LOCATION_TOKEN_VALUE(end_keyword)
     };
 
-    yp_string_shared_init(&node->name, name->start, name->end);
     return node;
 }
 
@@ -2748,7 +2746,7 @@ yp_match_required_node_create(yp_parser_t *parser, yp_node_t *value, yp_node_t *
 
 // Allocate a new ModuleNode node.
 static yp_module_node_t *
-yp_module_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *module_keyword, yp_node_t *constant_path, const yp_token_t *name, yp_node_t *body, const yp_token_t *end_keyword) {
+yp_module_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const yp_token_t *module_keyword, yp_node_t *constant_path, yp_node_t *body, const yp_token_t *end_keyword) {
     yp_module_node_t *node = YP_ALLOC_NODE(parser, yp_module_node_t);
 
     *node = (yp_module_node_t) {
@@ -2763,11 +2761,9 @@ yp_module_node_create(yp_parser_t *parser, yp_constant_id_list_t *locals, const
         .module_keyword_loc = YP_LOCATION_TOKEN_VALUE(module_keyword),
         .constant_path = constant_path,
         .body = body,
-        .end_keyword_loc = YP_LOCATION_TOKEN_VALUE(end_keyword),
-        .name = YP_EMPTY_STRING
+        .end_keyword_loc = YP_LOCATION_TOKEN_VALUE(end_keyword)
     };
 
-    yp_string_shared_init(&node->name, name->start, name->end);
     return node;
 }
 
@@ -4328,11 +4324,13 @@ parser_lex_encoding_comment_start(yp_parser_t *parser, const char *cursor, ptrdi
 
     const char *cursor_limit = cursor + length - key_length + 1;
     while ((cursor = yp_memchr(cursor, 'c', (size_t) (cursor_limit - cursor), parser->encoding_changed, &parser->encoding)) != NULL) {
-        if (
-            (strncmp(cursor, "coding", key_length - 1) == 0) &&
-            (cursor[key_length - 1] == ':' || cursor[key_length - 1] == '=')
-        ) {
-            return cursor + key_length;
+        if (strncmp(cursor, "coding", key_length - 1) == 0) {
+            size_t whitespace_after_coding = yp_strspn_inline_whitespace(cursor + key_length - 1, parser->end - (cursor + key_length - 1));
+            size_t cur_pos = key_length + whitespace_after_coding;
+
+            if (cursor[cur_pos - 1] == ':' || cursor[cur_pos - 1] == '=') {
+                return cursor + cur_pos;
+            }
         }
 
         cursor++;
@@ -10858,12 +10856,7 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
                 return (yp_node_t *) yp_singleton_class_node_create(parser, &locals, &class_keyword, &operator, expression, statements, &parser->previous);
             }
 
-            yp_node_t *constant_path = parse_expression(parser, YP_BINDING_POWER_INDEX, "Expected to find a class name after `class`.");
-            yp_token_t name = parser->previous;
-            if (name.type != YP_TOKEN_CONSTANT) {
-                yp_diagnostic_list_append(&parser->error_list, name.start, name.end, "Expected a constant name after `class`.");
-            }
-
+            yp_node_t *name = parse_expression(parser, YP_BINDING_POWER_INDEX, "Expected to find a class name after `class`.");
             yp_token_t inheritance_operator;
             yp_node_t *superclass;
 
@@ -10904,7 +10897,7 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
             yp_constant_id_list_t locals = parser->current_scope->locals;
             yp_parser_scope_pop(parser);
             yp_do_loop_stack_pop(parser);
-            return (yp_node_t *) yp_class_node_create(parser, &locals, &class_keyword, constant_path, &name, &inheritance_operator, superclass, statements, &parser->previous);
+            return (yp_node_t *) yp_class_node_create(parser, &locals, &class_keyword, name, &inheritance_operator, superclass, statements, &parser->previous);
         }
         case YP_TOKEN_KEYWORD_DEF: {
             yp_token_t def_keyword = parser->current;
@@ -11298,14 +11291,13 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
             parser_lex(parser);
 
             yp_token_t module_keyword = parser->previous;
-            yp_node_t *constant_path = parse_expression(parser, YP_BINDING_POWER_INDEX, "Expected to find a module name after `module`.");
-            yp_token_t name;
+            yp_node_t *name = parse_expression(parser, YP_BINDING_POWER_INDEX, "Expected to find a module name after `module`.");
 
-            // If we can recover from a syntax error that occurred while parsing
-            // the name of the module, then we'll handle that here.
-            if (YP_NODE_TYPE_P(constant_path, YP_NODE_MISSING_NODE)) {
-                yp_token_t missing = (yp_token_t) { .type = YP_TOKEN_MISSING, .start = parser->previous.end, .end = parser->previous.end };
-                return (yp_node_t *) yp_module_node_create(parser, NULL, &module_keyword, constant_path, &missing, NULL, &missing);
+            // If we can recover from a syntax error that occurred while parsing the
+            // name of the module, then we'll handle that here.
+            if (YP_NODE_TYPE_P(name, YP_NODE_MISSING_NODE)) {
+                yp_token_t end_keyword = (yp_token_t) { .type = YP_TOKEN_MISSING, .start = parser->previous.end, .end = parser->previous.end };
+                return (yp_node_t *) yp_module_node_create(parser, NULL, &module_keyword, name, NULL, &end_keyword);
             }
 
             while (accept(parser, YP_TOKEN_COLON_COLON)) {
@@ -11314,15 +11306,7 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
                 expect(parser, YP_TOKEN_CONSTANT, "Expected to find a module name after `::`.");
                 yp_node_t *constant = (yp_node_t *) yp_constant_read_node_create(parser, &parser->previous);
 
-                constant_path = (yp_node_t *) yp_constant_path_node_create(parser, constant_path, &double_colon, constant);
-            }
-
-            // Here we retrieve the name of the module. If it wasn't a constant,
-            // then it's possible that `module foo` was passed, which is a
-            // syntax error. We handle that here as well.
-            name = parser->previous;
-            if (name.type != YP_TOKEN_CONSTANT) {
-                yp_diagnostic_list_append(&parser->error_list, name.start, name.end, "Expected to find a module name after `module`.");
+                name = (yp_node_t *)yp_constant_path_node_create(parser, name, &double_colon, constant);
             }
 
             yp_parser_scope_push(parser, true);
@@ -11349,7 +11333,7 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
                 yp_diagnostic_list_append(&parser->error_list, module_keyword.start, module_keyword.end, "Module definition in method body");
             }
 
-            return (yp_node_t *) yp_module_node_create(parser, &locals, &module_keyword, constant_path, &name, statements, &parser->previous);
+            return (yp_node_t *) yp_module_node_create(parser, &locals, &module_keyword, name, statements, &parser->previous);
         }
         case YP_TOKEN_KEYWORD_NIL:
             parser_lex(parser);


Test patch:
diff --git a/test/encoding_test.rb b/test/encoding_test.rb
index 95d7bd32..c96a08e6 100644
--- a/test/encoding_test.rb
+++ b/test/encoding_test.rb
@@ -50,6 +50,13 @@ class EncodingTest < Test::Unit::TestCase
     assert_equal Encoding.find("utf-8"), actual
   end
 
+  def test_coding_with_whitespace
+    result = YARP.parse("# coding \t \r  \v   :     \t \v    \r   ascii-8bit \nident")
+    actual = result.value.statements.body.first.name.encoding
+    assert_equal Encoding.find("ascii-8bit"), actual
+  end
+
+
   def test_emacs_style
     result = YARP.parse("# -*- coding: utf-8 -*-\nident")
     actual = result.value.statements.body.first.name.encoding
diff --git a/test/errors_test.rb b/test/errors_test.rb
index d58fd274..9043ff35 100644
--- a/test/errors_test.rb
+++ b/test/errors_test.rb
@@ -18,10 +18,9 @@ class ErrorsTest < Test::Unit::TestCase
       Location(),
       ConstantReadNode(),
       StatementsNode(
-        [ModuleNode([], Location(), MissingNode(), nil, Location(), "")]
+        [ModuleNode([], Location(), MissingNode(), nil, Location())]
       ),
-      Location(),
-      "Parent"
+      Location()
     )
 
     assert_errors expected, "module Parent module end", [
@@ -392,7 +391,7 @@ class ErrorsTest < Test::Unit::TestCase
       Location(),
       nil,
       nil,
-      StatementsNode([ModuleNode([], Location(), ConstantReadNode(), nil, Location(), "A")]),
+      StatementsNode([ModuleNode([], Location(), ConstantReadNode(), nil, Location())]),
       [],
       Location(),
       nil,
@@ -423,7 +422,7 @@ class ErrorsTest < Test::Unit::TestCase
            BlockNode(
              [],
              nil,
-             StatementsNode([ModuleNode([], Location(), ConstantReadNode(), nil, Location(), "Foo")]),
+             StatementsNode([ModuleNode([], Location(), ConstantReadNode(), nil, Location())]),
              Location(),
              Location()
            ),
@@ -464,8 +463,7 @@ class ErrorsTest < Test::Unit::TestCase
            nil,
            nil,
            nil,
-           Location(),
-           "A"
+           Location()
          )]
       ),
       [],
@@ -965,8 +963,7 @@ class ErrorsTest < Test::Unit::TestCase
       nil,
       nil,
       StatementsNode([ReturnNode(Location(), nil)]),
-      Location(),
-      "A"
+      Location()
     )
 
     assert_errors expected, "class A; return; end", [
@@ -980,8 +977,7 @@ class ErrorsTest < Test::Unit::TestCase
       Location(),
       ConstantReadNode(),
       StatementsNode([ReturnNode(Location(), nil)]),
-      Location(),
-      "A"
+      Location()
     )
 
     assert_errors expected, "module A; return; end", [
diff --git a/test/snapshots/classes.txt b/test/snapshots/classes.txt
index 33b3d042..60ab0ead 100644
--- a/test/snapshots/classes.txt
+++ b/test/snapshots/classes.txt
@@ -16,8 +16,7 @@ ProgramNode(0...370)(
             (10...11)
           )]
        ),
-       (14...17),
-       "A"
+       (14...17)
      ),
      ClassNode(19...39)(
        [],
@@ -33,8 +32,7 @@ ProgramNode(0...370)(
          EnsureNode(28...39)((28...34), nil, (36...39)),
          (36...39)
        ),
-       (36...39),
-       "A"
+       (36...39)
      ),
      ClassNode(41...75)(
        [],
@@ -50,8 +48,7 @@ ProgramNode(0...370)(
          EnsureNode(64...75)((64...70), nil, (72...75)),
          (72...75)
        ),
-       (72...75),
-       "A"
+       (72...75)
      ),
      ClassNode(77...98)(
        [:a],
@@ -68,8 +65,7 @@ ProgramNode(0...370)(
             (91...92)
           )]
        ),
-       (95...98),
-       "A"
+       (95...98)
      ),
      SingletonClassNode(100...120)(
        [],
@@ -122,8 +118,7 @@ ProgramNode(0...370)(
             (154...157)
           )]
        ),
-       (159...162),
-       "A"
+       (159...162)
      ),
      ClassNode(164...218)(
        [],
@@ -148,8 +143,7 @@ ProgramNode(0...370)(
             (210...213)
           )]
        ),
-       (215...218),
-       "A"
+       (215...218)
      ),
      SingletonClassNode(220...240)(
        [],
@@ -280,8 +274,7 @@ ProgramNode(0...370)(
          "[]"
        ),
        nil,
-       (367...370),
-       "A"
+       (367...370)
      )]
   )
 )
diff --git a/test/snapshots/method_calls.txt b/test/snapshots/method_calls.txt
index b2c84d0d..f59fb7e4 100644
--- a/test/snapshots/method_calls.txt
+++ b/test/snapshots/method_calls.txt
@@ -1191,8 +1191,7 @@ ProgramNode(0...1237)(
                  "baz"
                )]
             ),
-            (926...929),
-            "Bar"
+            (926...929)
           )]
        ),
        nil,
@@ -1223,8 +1222,7 @@ ProgramNode(0...1237)(
                  "baz"
                )]
             ),
-            (957...960),
-            "Bar"
+            (957...960)
           )]
        ),
        nil,
diff --git a/test/snapshots/modules.txt b/test/snapshots/modules.txt
index a3cf30b9..705563a9 100644
--- a/test/snapshots/modules.txt
+++ b/test/snapshots/modules.txt
@@ -14,8 +14,7 @@ ProgramNode(0...140)(
             (11...12)
           )]
        ),
-       (15...18),
-       "A"
+       (15...18)
      ),
      InterpolatedStringNode(20...38)(
        (20...23),
@@ -49,8 +48,7 @@ ProgramNode(0...140)(
          (48...50)
        ),
        nil,
-       (52...55),
-       "M"
+       (52...55)
      ),
      ModuleNode(57...85)(
        [:x],
@@ -72,16 +70,14 @@ ProgramNode(0...140)(
          nil,
          (82...85)
        ),
-       (82...85),
-       "A"
+       (82...85)
      ),
      ModuleNode(87...101)(
        [],
        (87...93),
        ConstantPathNode(94...97)(nil, ConstantReadNode(96...97)(), (94...96)),
        nil,
-       (98...101),
-       "A"
+       (98...101)
      ),
      ModuleNode(103...120)(
        [],
@@ -102,8 +98,7 @@ ProgramNode(0...140)(
          (113...115)
        ),
        nil,
-       (117...120),
-       "B"
+       (117...120)
      ),
      ModuleNode(122...140)(
        [],
@@ -124,8 +119,7 @@ ProgramNode(0...140)(
          (133...135)
        ),
        nil,
-       (137...140),
-       "B"
+       (137...140)
      )]
   )
 )
diff --git a/test/snapshots/seattlerb/TestRubyParserShared.txt b/test/snapshots/seattlerb/TestRubyParserShared.txt
index 0eee2a39..cfad7e8a 100644
--- a/test/snapshots/seattlerb/TestRubyParserShared.txt
+++ b/test/snapshots/seattlerb/TestRubyParserShared.txt
@@ -86,8 +86,7 @@ ProgramNode(0...689)(
             (243...246)
           )]
        ),
-       (266...269),
-       "X"
+       (266...269)
      ),
      ClassNode(293...376)(
        [],
@@ -109,12 +108,10 @@ ProgramNode(0...689)(
                  (339...340)
                )]
             ),
-            (355...358),
-            "Y"
+            (355...358)
           )]
        ),
-       (373...376),
-       "X"
+       (373...376)
      ),
      ClassNode(395...498)(
        [],
@@ -160,8 +157,7 @@ ProgramNode(0...689)(
             (477...480)
           )]
        ),
-       (495...498),
-       "X"
+       (495...498)
      ),
      ModuleNode(517...565)(
        [],
@@ -179,8 +175,7 @@ ProgramNode(0...689)(
             (530...531)
           )]
        ),
-       (562...565),
-       "X"
+       (562...565)
      ),
      ModuleNode(568...651)(
        [],
@@ -198,12 +193,10 @@ ProgramNode(0...689)(
                  (614...615)
                )]
             ),
-            (630...633),
-            "Y"
+            (630...633)
           )]
        ),
-       (648...651),
-       "X"
+       (648...651)
      ),
      CallNode(670...689)(
        nil,
diff --git a/test/snapshots/seattlerb/class_comments.txt b/test/snapshots/seattlerb/class_comments.txt
index b96c5d63..12b347ee 100644
--- a/test/snapshots/seattlerb/class_comments.txt
+++ b/test/snapshots/seattlerb/class_comments.txt
@@ -22,8 +22,7 @@ ProgramNode(19...71)(
             (64...67)
           )]
        ),
-       (68...71),
-       "X"
+       (68...71)
      )]
   )
 )
diff --git a/test/snapshots/seattlerb/defn_oneliner_eq2.txt b/test/snapshots/seattlerb/defn_oneliner_eq2.txt
index d5798209..30aaf719 100644
--- a/test/snapshots/seattlerb/defn_oneliner_eq2.txt
+++ b/test/snapshots/seattlerb/defn_oneliner_eq2.txt
@@ -30,8 +30,7 @@ ProgramNode(0...28)(
             nil
           )]
        ),
-       (25...28),
-       "X"
+       (25...28)
      )]
   )
 )
diff --git a/test/snapshots/seattlerb/defs_oneliner_eq2.txt b/test/snapshots/seattlerb/defs_oneliner_eq2.txt
index 2ec8dc86..8a4f9e90 100644
--- a/test/snapshots/seattlerb/defs_oneliner_eq2.txt
+++ b/test/snapshots/seattlerb/defs_oneliner_eq2.txt
@@ -30,8 +30,7 @@ ProgramNode(0...33)(
             nil
           )]
        ),
-       (30...33),
-       "X"
+       (30...33)
      )]
   )
 )
diff --git a/test/snapshots/seattlerb/magic_encoding_comment.txt b/test/snapshots/seattlerb/magic_encoding_comment.txt
index 08c8d9ea..2ab320ed 100644
--- a/test/snapshots/seattlerb/magic_encoding_comment.txt
+++ b/test/snapshots/seattlerb/magic_encoding_comment.txt
@@ -30,8 +30,7 @@ ProgramNode(18...90)(
             (83...86)
           )]
        ),
-       (87...90),
-       "ExampleUTF8ClassNameVarietà"
+       (87...90)
      )]
   )
 )
diff --git a/test/snapshots/seattlerb/module_comments.txt b/test/snapshots/seattlerb/module_comments.txt
index 4f399904..808f4799 100644
--- a/test/snapshots/seattlerb/module_comments.txt
+++ b/test/snapshots/seattlerb/module_comments.txt
@@ -20,8 +20,7 @@ ProgramNode(24...77)(
             (70...73)
           )]
        ),
-       (74...77),
-       "X"
+       (74...77)
      )]
   )
 )
diff --git a/test/snapshots/seattlerb/parse_line_heredoc_hardnewline.txt b/test/snapshots/seattlerb/parse_line_heredoc_hardnewline.txt
index 4445e447..4f7ae811 100644
--- a/test/snapshots/seattlerb/parse_line_heredoc_hardnewline.txt
+++ b/test/snapshots/seattlerb/parse_line_heredoc_hardnewline.txt
@@ -18,8 +18,7 @@ ProgramNode(0...48)(
        nil,
        nil,
        nil,
-       (45...48),
-       "Foo"
+       (45...48)
      )]
   )
 )
diff --git a/test/snapshots/unparser/corpus/literal/class.txt b/test/snapshots/unparser/corpus/literal/class.txt
index aa457618..96b50c7a 100644
--- a/test/snapshots/unparser/corpus/literal/class.txt
+++ b/test/snapshots/unparser/corpus/literal/class.txt
@@ -8,8 +8,7 @@ ProgramNode(0...213)(
        nil,
        nil,
        nil,
-       (8...11),
-       "A"
+       (8...11)
      ),
      SingletonClassNode(13...27)(
        [],
@@ -40,8 +39,7 @@ ProgramNode(0...213)(
        nil,
        nil,
        nil,
-       (60...63),
-       "B"
+       (60...63)
      ),
      ClassNode(65...82)(
        [],
@@ -58,8 +56,7 @@ ProgramNode(0...213)(
        nil,
        nil,
        nil,
-       (79...82),
-       "C"
+       (79...82)
      ),
      ClassNode(84...99)(
        [],
@@ -68,8 +65,7 @@ ProgramNode(0...213)(
        (92...93),
        ConstantReadNode(94...95)(),
        nil,
-       (96...99),
-       "A"
+       (96...99)
      ),
      ClassNode(101...119)(
        [],
@@ -82,8 +78,7 @@ ProgramNode(0...213)(
          (112...114)
        ),
        nil,
-       (116...119),
-       "A"
+       (116...119)
      ),
      ClassNode(121...142)(
        [],
@@ -100,8 +95,7 @@ ProgramNode(0...213)(
          (135...137)
        ),
        nil,
-       (139...142),
-       "B"
+       (139...142)
      ),
      ClassNode(144...198)(
        [],
@@ -149,8 +143,7 @@ ProgramNode(0...213)(
             (191...194)
           )]
        ),
-       (195...198),
-       "A"
+       (195...198)
      ),
      ClassNode(200...213)(
        [],
@@ -163,8 +156,7 @@ ProgramNode(0...213)(
        nil,
        nil,
        nil,
-       (210...213),
-       "A"
+       (210...213)
      )]
   )
 )
diff --git a/test/snapshots/unparser/corpus/literal/if.txt b/test/snapshots/unparser/corpus/literal/if.txt
index 1bfbe7e2..8375e9ac 100644
--- a/test/snapshots/unparser/corpus/literal/if.txt
+++ b/test/snapshots/unparser/corpus/literal/if.txt
@@ -80,8 +80,7 @@ ProgramNode(0...246)(
             nil
           )]
        ),
-       (130...133),
-       "A"
+       (130...133)
      ),
      ModuleNode(135...170)(
        [:foo],
@@ -114,8 +113,7 @@ ProgramNode(0...246)(
             nil
           )]
        ),
-       (167...170),
-       "B"
+       (167...170)
      ),
      UnlessNode(171...197)(
        (171...177),
diff --git a/test/snapshots/unparser/corpus/literal/module.txt b/test/snapshots/unparser/corpus/literal/module.txt
index 4c805d3d..c917fedd 100644
--- a/test/snapshots/unparser/corpus/literal/module.txt
+++ b/test/snapshots/unparser/corpus/literal/module.txt
@@ -1,14 +1,7 @@
 ProgramNode(0...106)(
   [],
   StatementsNode(0...106)(
-    [ModuleNode(0...12)(
-       [],
-       (0...6),
-       ConstantReadNode(7...8)(),
-       nil,
-       (9...12),
-       "A"
-     ),
+    [ModuleNode(0...12)([], (0...6), ConstantReadNode(7...8)(), nil, (9...12)),
      ModuleNode(14...29)(
        [],
        (14...20),
@@ -18,8 +11,7 @@ ProgramNode(0...106)(
          (22...24)
        ),
        nil,
-       (26...29),
-       "B"
+       (26...29)
      ),
      ModuleNode(31...49)(
        [],
@@ -34,8 +26,7 @@ ProgramNode(0...106)(
          (42...44)
        ),
        nil,
-       (46...49),
-       "C"
+       (46...49)
      ),
      ModuleNode(51...106)(
        [],
@@ -81,8 +72,7 @@ ProgramNode(0...106)(
             (99...102)
           )]
        ),
-       (103...106),
-       "A"
+       (103...106)
      )]
   )
 )
diff --git a/test/snapshots/unparser/corpus/literal/send.txt b/test/snapshots/unparser/corpus/literal/send.txt
index 083a0140..2c2ce8cd 100644
--- a/test/snapshots/unparser/corpus/literal/send.txt
+++ b/test/snapshots/unparser/corpus/literal/send.txt
@@ -47,8 +47,7 @@ ProgramNode(0...999)(
             (15...18)
           )]
        ),
-       (32...35),
-       "A"
+       (32...35)
      ),
      ModuleNode(37...73)(
        [:local],
@@ -74,8 +73,7 @@ ProgramNode(0...999)(
             "bar"
           )]
        ),
-       (70...73),
-       "A"
+       (70...73)
      ),
      CallNode(74...89)(
        ClassNode(74...85)(
@@ -85,8 +83,7 @@ ProgramNode(0...999)(
          nil,
          nil,
          nil,
-         (82...85),
-         "A"
+         (82...85)
        ),
        (85...86),
        (86...89),
@@ -103,8 +100,7 @@ ProgramNode(0...999)(
          (90...96),
          ConstantReadNode(97...98)(),
          nil,
-         (99...102),
-         "A"
+         (99...102)
        ),
        (102...103),
        (103...106),
diff --git a/test/snapshots/unparser/corpus/literal/while.txt b/test/snapshots/unparser/corpus/literal/while.txt
index dae7e0f0..98088460 100644
--- a/test/snapshots/unparser/corpus/literal/while.txt
+++ b/test/snapshots/unparser/corpus/literal/while.txt
@@ -62,8 +62,7 @@ ProgramNode(0...620)(
             "foo"
           )]
        ),
-       (65...68),
-       "A"
+       (65...68)
      ),
      DefNode(70...110)(
        (74...77),
@@ -155,8 +154,7 @@ ProgramNode(0...620)(
             0
           )]
        ),
-       (143...146),
-       "A"
+       (143...146)
      ),
      ModuleNode(148...182)(
        [:foo],
@@ -188,8 +186,7 @@ ProgramNode(0...620)(
             0
           )]
        ),
-       (179...182),
-       "A"
+       (179...182)
      ),
      ModuleNode(184...228)(
        [:foo],
@@ -231,8 +228,7 @@ ProgramNode(0...620)(
             0
           )]
        ),
-       (225...228),
-       "A"
+       (225...228)
      ),
      ModuleNode(230...299)(
        [],
@@ -305,8 +301,7 @@ ProgramNode(0...620)(
             "each"
           )]
        ),
-       (296...299),
-       "A"
+       (296...299)
      ),
      ModuleNode(301...370)(
        [],
@@ -369,8 +364,7 @@ ProgramNode(0...620)(
             "each"
           )]
        ),
-       (367...370),
-       "A"
+       (367...370)
      ),
      LocalVariableWriteNode(371...402)(
        :x,
diff --git a/test/snapshots/unparser/corpus/semantic/while.txt b/test/snapshots/unparser/corpus/semantic/while.txt
index 148db33d..fd495fbd 100644
--- a/test/snapshots/unparser/corpus/semantic/while.txt
+++ b/test/snapshots/unparser/corpus/semantic/while.txt
@@ -178,8 +178,7 @@ ProgramNode(0...188)(
             0
           )]
        ),
-       (185...188),
-       "A"
+       (185...188)
      )]
   )
 )
diff --git a/test/snapshots/while.txt b/test/snapshots/while.txt
index 484eb68b..cc0d2fbf 100644
--- a/test/snapshots/while.txt
+++ b/test/snapshots/while.txt
@@ -130,8 +130,7 @@ ProgramNode(0...314)(
               (181...182)
             )]
          ),
-         (195...198),
-         "Foo"
+         (195...198)
        ),
        StatementsNode(200...205)([BreakNode(200...205)(nil, (200...205))]),
        0
diff --git a/test/snapshots/whitequark/class.txt b/test/snapshots/whitequark/class.txt
index c176350d..0061b34a 100644
--- a/test/snapshots/whitequark/class.txt
+++ b/test/snapshots/whitequark/class.txt
@@ -8,8 +8,7 @@ ProgramNode(0...29)(
        nil,
        nil,
        nil,
-       (10...13),
-       "Foo"
+       (10...13)
      ),
      ClassNode(15...29)(
        [],
@@ -18,8 +17,7 @@ ProgramNode(0...29)(
        nil,
        nil,
        nil,
-       (26...29),
-       "Foo"
+       (26...29)
      )]
   )
 )
diff --git a/test/snapshots/whitequark/class_definition_in_while_cond.txt b/test/snapshots/whitequark/class_definition_in_while_cond.txt
index 0af9f40e..a7bee91d 100644
--- a/test/snapshots/whitequark/class_definition_in_while_cond.txt
+++ b/test/snapshots/whitequark/class_definition_in_while_cond.txt
@@ -84,8 +84,7 @@ ProgramNode(0...197)(
               (122...123)
             )]
          ),
-         (136...139),
-         "Foo"
+         (136...139)
        ),
        StatementsNode(141...146)([BreakNode(141...146)(nil, (141...146))]),
        0
@@ -111,8 +110,7 @@ ProgramNode(0...197)(
               "tap"
             )]
          ),
-         (182...185),
-         "Foo"
+         (182...185)
        ),
        StatementsNode(187...192)([BreakNode(187...192)(nil, (187...192))]),
        0
diff --git a/test/snapshots/whitequark/class_super.txt b/test/snapshots/whitequark/class_super.txt
index 3dda8280..aa2845a1 100644
--- a/test/snapshots/whitequark/class_super.txt
+++ b/test/snapshots/whitequark/class_super.txt
@@ -8,8 +8,7 @@ ProgramNode(0...20)(
        (10...11),
        ConstantReadNode(12...15)(),
        nil,
-       (17...20),
-       "Foo"
+       (17...20)
      )]
   )
 )
diff --git a/test/snapshots/whitequark/class_super_label.txt b/test/snapshots/whitequark/class_super_label.txt
index 17e92e16..ae6759c1 100644
--- a/test/snapshots/whitequark/class_super_label.txt
+++ b/test/snapshots/whitequark/class_super_label.txt
@@ -20,8 +20,7 @@ ProgramNode(0...20)(
          "a"
        ),
        nil,
-       (17...20),
-       "Foo"
+       (17...20)
      )]
   )
 )
diff --git a/test/snapshots/whitequark/cpath.txt b/test/snapshots/whitequark/cpath.txt
index 2f838711..94714a1a 100644
--- a/test/snapshots/whitequark/cpath.txt
+++ b/test/snapshots/whitequark/cpath.txt
@@ -6,8 +6,7 @@ ProgramNode(0...39)(
        (0...6),
        ConstantPathNode(7...12)(nil, ConstantReadNode(9...12)(), (7...9)),
        nil,
-       (14...17),
-       "Foo"
+       (14...17)
      ),
      ModuleNode(19...39)(
        [],
@@ -18,8 +17,7 @@ ProgramNode(0...39)(
          (29...31)
        ),
        nil,
-       (36...39),
-       "Foo"
+       (36...39)
      )]
   )
 )
diff --git a/test/snapshots/whitequark/if_while_after_class__since_32.txt b/test/snapshots/whitequark/if_while_after_class__since_32.txt
index 2096097f..77f26487 100644
--- a/test/snapshots/whitequark/if_while_after_class__since_32.txt
+++ b/test/snapshots/whitequark/if_while_after_class__since_32.txt
@@ -18,8 +18,7 @@ ProgramNode(0...178)(
        nil,
        nil,
        nil,
-       (35...38),
-       "Kernel"
+       (35...38)
      ),
      ClassNode(40...87)(
        [],
@@ -42,8 +41,7 @@ ProgramNode(0...178)(
        nil,
        nil,
        nil,
-       (84...87),
-       "Kernel"
+       (84...87)
      ),
      ModuleNode(89...128)(
        [],
@@ -60,8 +58,7 @@ ProgramNode(0...178)(
          (115...117)
        ),
        nil,
-       (125...128),
-       "Kernel"
+       (125...128)
      ),
      ModuleNode(130...178)(
        [],
@@ -82,8 +79,7 @@ ProgramNode(0...178)(
          (165...167)
        ),
        nil,
-       (175...178),
-       "Kernel"
+       (175...178)
      )]
   )
 )
diff --git a/test/snapshots/whitequark/module.txt b/test/snapshots/whitequark/module.txt
index 1695fb8f..54fccb1f 100644
--- a/test/snapshots/whitequark/module.txt
+++ b/test/snapshots/whitequark/module.txt
@@ -6,8 +6,7 @@ ProgramNode(0...15)(
        (0...6),
        ConstantReadNode(7...10)(),
        nil,
-       (12...15),
-       "Foo"
+       (12...15)
      )]
   )
 )
diff --git a/test/snapshots/whitequark/numparam_outside_block.txt b/test/snapshots/whitequark/numparam_outside_block.txt
index ac120e81..99cb79b9 100644
--- a/test/snapshots/whitequark/numparam_outside_block.txt
+++ b/test/snapshots/whitequark/numparam_outside_block.txt
@@ -21,8 +21,7 @@ ProgramNode(0...83)(
        StatementsNode(36...38)(
          [CallNode(36...38)(nil, nil, (36...38), nil, nil, nil, nil, 2, "_1")]
        ),
-       (40...43),
-       "A"
+       (40...43)
      ),
      DefNode(45...64)(
        (54...55),
@@ -46,8 +45,7 @@ ProgramNode(0...83)(
        StatementsNode(76...78)(
          [CallNode(76...78)(nil, nil, (76...78), nil, nil, nil, nil, 2, "_1")]
        ),
-       (80...83),
-       "A"
+       (80...83)
      )]
   )
 )
diff --git a/test/snapshots/whitequark/parser_bug_490.txt b/test/snapshots/whitequark/parser_bug_490.txt
index 8ea556d9..6f4c3a84 100644
--- a/test/snapshots/whitequark/parser_bug_490.txt
+++ b/test/snapshots/whitequark/parser_bug_490.txt
@@ -47,8 +47,7 @@ ProgramNode(0...132)(
                  nil,
                  nil,
                  nil,
-                 (72...75),
-                 "C"
+                 (72...75)
                )]
             ),
             (77...80)
@@ -78,8 +77,7 @@ ProgramNode(0...132)(
                  (109...115),
                  ConstantReadNode(116...117)(),
                  nil,
-                 (119...122),
-                 "M"
+                 (119...122)
                )]
             ),
             (124...127)
diff --git a/test/snapshots/whitequark/parser_bug_518.txt b/test/snapshots/whitequark/parser_bug_518.txt
index bee652b2..4de48dad 100644
--- a/test/snapshots/whitequark/parser_bug_518.txt
+++ b/test/snapshots/whitequark/parser_bug_518.txt
@@ -8,8 +8,7 @@ ProgramNode(0...15)(
        (8...9),
        ConstantReadNode(10...11)(),
        nil,
-       (12...15),
-       "A"
+       (12...15)
      )]
   )
 )