Skip to content

Commit 22a6993

Browse files
committed
Translate another example
1 parent 6ae39dd commit 22a6993

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

parser/prism/Translator.cc

+13-3
Original file line numberDiff line numberDiff line change
@@ -1076,14 +1076,24 @@ std::unique_ptr<parser::Node> Translator::translateConstantPath(pm_constant_path
10761076
} else { // This is a fully qualified constant reference, like `::A`.
10771077
pm_location_t *delimiterLoc = &node->delimiter_loc; // The location of the `::`
10781078
parent = make_node<parser::Cbase>(parser.translateLocation(delimiterLoc));
1079+
parent->cacheDesugaredExpr(MK::Constant(parent->loc, core::Symbols::root()));
10791080
}
10801081

1082+
auto parentExpr = parent->getCachedDesugaredExpr();
1083+
ENFORCE(parentExpr != nullptr);
1084+
1085+
auto sorbetName = gs.enterNameConstant(name);
1086+
1087+
unique_ptr<parser::Node> sorbetNode;
10811088
if (isAssignment) {
1082-
return make_node<parser::ConstLhs>(parser.translateLocation(loc), std::move(parent),
1083-
gs.enterNameConstant(name));
1089+
sorbetNode = make_node<parser::ConstLhs>(parser.translateLocation(loc), std::move(parent), sorbetName);
10841090
} else {
1085-
return make_node<parser::Const>(parser.translateLocation(loc), std::move(parent), gs.enterNameConstant(name));
1091+
sorbetNode = make_node<parser::Const>(parser.translateLocation(loc), std::move(parent), sorbetName);
10861092
}
1093+
1094+
sorbetNode->cacheDesugaredExpr(MK::UnresolvedConstant(sorbetNode->loc, std::move(parentExpr), sorbetName));
1095+
1096+
return sorbetNode;
10871097
}
10881098

10891099
// Translate a node that only has basic location information, and nothing else. E.g. `true`, `nil`, `it`.

0 commit comments

Comments
 (0)