Skip to content

Commit

Permalink
Merge pull request #396 from Shopify/fix-#342
Browse files Browse the repository at this point in the history
Correctly translate constant write nodes' location
  • Loading branch information
st0012 authored Jan 6, 2025
2 parents 29be814 + 237ed5c commit 1c1fa84
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
8 changes: 8 additions & 0 deletions parser/prism/Translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,14 @@ unique_ptr<parser::Node> Translator::translateConst(PrismLhsNode *node, bool rep
is_same_v<PrismLhsNode, pm_constant_operator_write_node> ||
is_same_v<PrismLhsNode, pm_constant_target_node> || is_same_v<PrismLhsNode, pm_constant_read_node> ||
is_same_v<PrismLhsNode, pm_constant_write_node>);

// For writes, location should only include the name, like `FOO` in `FOO = 1`.
if constexpr (is_same_v<PrismLhsNode, pm_constant_and_write_node> ||
is_same_v<PrismLhsNode, pm_constant_or_write_node> ||
is_same_v<PrismLhsNode, pm_constant_operator_write_node> ||
is_same_v<PrismLhsNode, pm_constant_write_node>) {
location = translateLoc(node->name_loc);
}
parent = nullptr;
}

Expand Down
11 changes: 0 additions & 11 deletions test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,6 @@ pipeline_tests(
"testdata/lsp/completion/self_receiver.rb",

# Desugar tests having to do with tree differences; will address later
"testdata/desugar/constant_error.rb",
"testdata/desugar/for.rb",
"testdata/desugar/sclass.rb",

# Rewriter tests having to do with symbol table differences; will address later
Expand All @@ -306,17 +304,8 @@ pipeline_tests(
"testdata/rewriter/struct.rb",

# Failing namer tests to investigate
"testdata/namer/alias_cross_file__01.rb",
"testdata/namer/alias_cross_file__02.rb",
"testdata/namer/all_constant_redefinitions.rb",
"testdata/namer/class_alias_inside_method.rb",
"testdata/namer/class_and_alias.rb",
"testdata/namer/constant_in_block.rb",
"testdata/namer/constant_types.rb",
"testdata/namer/constants.rb",
"testdata/namer/fuzz_class_in_field.rb",
"testdata/namer/fuzz_repeated_kwarg.rb",
"testdata/namer/fuzz_type_template_overwrite.rb",
"testdata/namer/module_function.rb",
"testdata/namer/parameter_names.rb",
"testdata/namer/redefinition_method.rb",
Expand Down

0 comments on commit 1c1fa84

Please sign in to comment.