diff --git a/parser/prism/Translator.cc b/parser/prism/Translator.cc index a7069b74b2d..18a0c73280a 100644 --- a/parser/prism/Translator.cc +++ b/parser/prism/Translator.cc @@ -1261,13 +1261,19 @@ unique_ptr Translator::translate(pm_node_t *node) { returnValues = translateArguments(superNode->arguments, blockArgumentNode); return make_unique(location, move(returnValues)); } - case PM_SYMBOL_NODE: { // A symbol literal, e.g. `:foo` + case PM_SYMBOL_NODE: { // A symbol literal, e.g. `:foo`, or `a:` in `{a: 1}` auto symNode = down_cast(node); auto unescaped = &symNode->unescaped; auto source = parser.extractString(unescaped); + // If the opening location is null, the symbol is used as a key with a colon postfix, like `{a: 1}` + // In those cases, the location should not include the colon. + if (symNode->opening_loc.start == nullptr) { + location = translateLoc(symNode->value_loc); + } + // TODO: can these have different encodings? return make_unique(location, gs.enterNameUTF8(source)); } diff --git a/test/BUILD b/test/BUILD index 09c04022827..edfdcf4eec5 100644 --- a/test/BUILD +++ b/test/BUILD @@ -261,18 +261,8 @@ pipeline_tests( [ # Replace [parser] with other phases to test Prism at that level # Phases: https://github.com/Shopify/sorbet/blob/prism/docs/internals.md#phases - "testdata/parser/**/*.rb", - "testdata/parser/**/*.exp", - "testdata/desugar/**/*.rb", - "testdata/desugar/**/*.exp", - "testdata/rewriter/**/*.rb", - "testdata/rewriter/**/*.exp", - "testdata/local_vars/**/*.rb", - "testdata/local_vars/**/*.exp", - "testdata/namer/**/*.rb", - "testdata/namer/**/*.exp", - "testdata/lsp/**/*.rb", - "testdata/lsp/**/*.exp", + "testdata/**/*.rb", + "testdata/**/*.exp", ], exclude = [ # Tests having to do with tree differences in invalid Ruby code; will address later @@ -293,26 +283,8 @@ pipeline_tests( "testdata/lsp/completion/missing_const_name.rb", "testdata/lsp/completion/missing_fun.rb", "testdata/lsp/completion/self_receiver.rb", - - # Desugar tests having to do with tree differences; will address later - "testdata/desugar/sclass.rb", - - # Rewriter tests having to do with symbol table differences; will address later - "testdata/rewriter/attr_multi.rb", - "testdata/rewriter/attr.rb", - "testdata/rewriter/prop.rb", - "testdata/rewriter/struct.rb", - - # Failing namer tests to investigate - "testdata/namer/class_alias_inside_method.rb", "testdata/namer/fuzz_repeated_kwarg.rb", - "testdata/namer/module_function.rb", - "testdata/namer/parameter_names.rb", - "testdata/namer/redefinition_method.rb", - "testdata/namer/type_alias_inside_method.rb", - "testdata/namer/type_alias.rb", - "testdata/namer/type_member_inside_method.rb", - "testdata/namer/type_template_inside_method.rb", + "testdata/deviations/keyword_method_names.rb", # Sorbets' parser incorrectly accepts invalid syntax "testdata/desugar/pattern_matching_hash.rb", # See https://github.com/Shopify/sorbet/issues/362