@@ -328,8 +328,8 @@ ast::ExpressionPtr Translator::desugarDString(core::LocOffsets loc, pm_node_list
328328ast::ExpressionPtr Translator::desugarMlhs (core::LocOffsets loc, parser::Mlhs *lhs, ast::ExpressionPtr rhs) {
329329 ast::InsSeq::STATS_store stats;
330330
331- core::NameRef tempRhs = nextUniqueDesugarName (core::Names::assignTemp ());
332- core::NameRef tempExpanded = nextUniqueDesugarName (core::Names::assignTemp ());
331+ core::NameRef tempRhs = nextUniqueName (core::Names::assignTemp ());
332+ core::NameRef tempExpanded = nextUniqueName (core::Names::assignTemp ());
333333
334334 int i = 0 ;
335335 int before = 0 , after = 0 ;
@@ -536,7 +536,7 @@ unique_ptr<parser::Node> Translator::translateAndOrAssignment(core::LocOffsets l
536536 assgnArgs.emplace_back (move (rhsExpr));
537537 auto cond =
538538 MK::Send (sendLoc, MK::Local (sendLoc, tempRecv), s->fun , s->funLoc , numPosArgs, move (readArgs), s->flags );
539- auto tempResult = nextUniqueDesugarName (s->fun );
539+ auto tempResult = nextUniqueName (s->fun );
540540 stats.emplace_back (MK::Assign (sendLoc, tempResult, move (cond)));
541541 auto body = MK::Send (sendLoc, MK::Local (sendLoc, tempRecv), s->fun .addEq (ctx), sendLoc.copyWithZeroLength (),
542542 numPosAssgnArgs, move (assgnArgs), s->flags );
@@ -575,7 +575,7 @@ unique_ptr<parser::Node> Translator::translateAndOrAssignment(core::LocOffsets l
575575 auto decl = MK::Assign (location, MK::cpRef (lhsExpr), move (rhsExpr));
576576
577577 // Create a temporary variable and assign the original value to it
578- core::NameRef tempName = nextUniqueDesugarName (core::Names::statTemp ());
578+ core::NameRef tempName = nextUniqueName (core::Names::statTemp ());
579579 auto tempAssign = MK::Assign (location, tempName, move (originalValue));
580580
581581 // Final assignment from temp to LHS
@@ -626,7 +626,7 @@ unique_ptr<parser::Node> Translator::translateAndOrAssignment(core::LocOffsets l
626626 assgnArgs.emplace_back (move (rhsExpr));
627627 auto cond =
628628 MK::Send (sendLoc, MK::Local (sendLoc, tempRecv), s->fun , s->funLoc , numPosArgs, move (readArgs), s->flags );
629- auto tempResult = nextUniqueDesugarName (s->fun );
629+ auto tempResult = nextUniqueName (s->fun );
630630 stats.emplace_back (MK::Assign (sendLoc, tempResult, move (cond)));
631631 auto body = MK::Send (sendLoc, MK::Local (sendLoc, tempRecv), s->fun .addEq (ctx), sendLoc.copyWithZeroLength (),
632632 numPosAssgnArgs, move (assgnArgs), s->flags );
@@ -652,7 +652,7 @@ Translator::OpAsgnScaffolding Translator::copyArgsForOpAsgn(ast::Send *s) {
652652 const auto numPosArgs = s->numPosArgs ();
653653 ast::InsSeq::STATS_store stats;
654654 stats.reserve (numPosArgs + 2 );
655- core::NameRef tempRecv = nextUniqueDesugarName (s->fun );
655+ core::NameRef tempRecv = nextUniqueName (s->fun );
656656 stats.emplace_back (MK::Assign (s->loc , tempRecv, move (s->recv )));
657657 ast::Send::ARGS_store readArgs;
658658 ast::Send::ARGS_store assgnArgs;
@@ -665,7 +665,7 @@ Translator::OpAsgnScaffolding Translator::copyArgsForOpAsgn(ast::Send *s) {
665665
666666 for (auto &arg : s->posArgs ()) {
667667 auto argLoc = arg.loc ();
668- core::NameRef name = nextUniqueDesugarName (s->fun );
668+ core::NameRef name = nextUniqueName (s->fun );
669669 stats.emplace_back (MK::Assign (argLoc, name, move (arg)));
670670 readArgs.emplace_back (MK::Local (argLoc, name));
671671 assgnArgs.emplace_back (MK::Local (argLoc, name));
@@ -819,7 +819,7 @@ unique_ptr<parser::Node> Translator::translateCSendAssignment(PrismAssignmentNod
819819 }
820820
821821 // Create temporary variable to hold the receiver
822- auto tempRecv = nextUniqueDesugarName (core::Names::assignTemp ());
822+ auto tempRecv = nextUniqueName (core::Names::assignTemp ());
823823 auto receiverExpr = receiver->takeDesugaredExpr ();
824824 auto recvLoc = receiver->loc ;
825825 auto zeroLengthLoc = location.copyWithZeroLength ();
@@ -968,7 +968,7 @@ unique_ptr<parser::Node> Translator::translate(pm_node_t *node) {
968968
969969 // For non-reference expressions, create a temporary variable so we don't evaluate the LHS twice.
970970 // E.g. `x = 1 && 2` becomes `x = (temp = 1; temp ? temp : 2)`
971- core::NameRef tempLocalName = nextUniqueDesugarName (core::Names::andAnd ());
971+ core::NameRef tempLocalName = nextUniqueName (core::Names::andAnd ());
972972
973973 bool checkAndAnd = ast::isa_tree<ast::Send>(lhsExpr) && ast::isa_tree<ast::Send>(rhsExpr);
974974 ExpressionPtr thenp;
@@ -1874,7 +1874,7 @@ unique_ptr<parser::Node> Translator::translate(pm_node_t *node) {
18741874
18751875 if (predicate != nullptr ) {
18761876 predicateLoc = predicate->loc ;
1877- tempName = nextUniqueDesugarName (core::Names::assignTemp ());
1877+ tempName = nextUniqueName (core::Names::assignTemp ());
18781878 } else {
18791879 tempName = core::NameRef::noName ();
18801880 }
@@ -1999,7 +1999,7 @@ unique_ptr<parser::Node> Translator::translate(pm_node_t *node) {
19991999
20002000 if (hasPredicate) {
20012001 predicateLoc = predicate->loc ;
2002- tempName = nextUniqueDesugarName (core::Names::assignTemp ());
2002+ tempName = nextUniqueName (core::Names::assignTemp ());
20032003 } else {
20042004 tempName = core::NameRef::noName ();
20052005 }
@@ -2483,7 +2483,7 @@ unique_ptr<parser::Node> Translator::translate(pm_node_t *node) {
24832483 }
24842484 } else {
24852485 // Complex case: `for @x in a; body; end` -> `a.each { || @x = <temp>; body }`
2486- auto temp = nextUniqueDesugarName (core::Names::forTemp ());
2486+ auto temp = nextUniqueName (core::Names::forTemp ());
24872487 auto tempLocal = MK::Local (location, temp);
24882488
24892489 // Desugar the assignment
@@ -3148,7 +3148,7 @@ unique_ptr<parser::Node> Translator::translate(pm_node_t *node) {
31483148
31493149 // For non-reference expressions, create a temporary variable so we don't evaluate the LHS twice.
31503150 // E.g. `x = 1 || 2` becomes `x = (temp = 1; temp ? temp : 2)`
3151- core::NameRef tempLocalName = nextUniqueDesugarName (core::Names::orOr ());
3151+ core::NameRef tempLocalName = nextUniqueName (core::Names::orOr ());
31523152 auto lhsLoc = left->loc ;
31533153 auto rhsLoc = right->loc ;
31543154 auto condLoc =
@@ -3302,7 +3302,7 @@ unique_ptr<parser::Node> Translator::translate(pm_node_t *node) {
33023302
33033303 // Create a RescueCase with empty exceptions and a <rescueTemp> variable
33043304 ast::RescueCase::EXCEPTION_store exceptions;
3305- auto rescueTemp = nextUniqueDesugarName (core::Names::rescueTemp ());
3305+ auto rescueTemp = nextUniqueName (core::Names::rescueTemp ());
33063306
33073307 auto rescueCaseLoc =
33083308 translateLoc (rescueModifierNode->keyword_loc .start , rescueModifierNode->base .location .end );
@@ -4469,7 +4469,7 @@ ast::ExpressionPtr Translator::desugarSymbolProc(pm_symbol_node *symbol) {
44694469 auto loc0 = loc.copyWithZeroLength (); // TODO: shorten name
44704470
44714471 // `temp` does not refer to any specific source text, so give it a 0-length Loc so LSP ignores it.
4472- core::NameRef tempName = nextUniqueDesugarName (core::Names::blockPassTemp ());
4472+ core::NameRef tempName = nextUniqueName (core::Names::blockPassTemp ());
44734473
44744474 // `temp[0]`
44754475 auto recv = MK::Send1 (loc0, MK::Local (loc0, tempName), core::Names::squareBrackets (), loc0, MK::Int (loc0, 0 ));
@@ -4694,7 +4694,7 @@ ast::ExpressionPtr Translator::desugarHash(core::LocOffsets loc, NodeVec &kvPair
46944694 ast::InsSeq::STATS_store updateStmts;
46954695 updateStmts.reserve (kvPairs.size ());
46964696
4697- auto acc = nextUniqueDesugarName (core::Names::hashTemp ());
4697+ auto acc = nextUniqueName (core::Names::hashTemp ());
46984698
46994699 ast::desugar::DuplicateHashKeyCheck hashKeyDupes (ctx);
47004700 ast::Send::ARGS_store mergeValues;
@@ -5068,7 +5068,7 @@ unique_ptr<parser::Node> Translator::translateRescue(pm_begin_node *parentBeginN
50685068 } else if (isReference) {
50695069 // Non-local reference (lvalue exception variables like @ex, @@ex, $ex)
50705070 // Create a temp variable and wrap the body
5071- auto rescueTemp = nextUniqueDesugarName (core::Names::rescueTemp ());
5071+ auto rescueTemp = nextUniqueName (core::Names::rescueTemp ());
50725072 auto varLoc = var->loc ;
50735073 varExpr = ast::MK::Local (varLoc, rescueTemp);
50745074
@@ -5085,7 +5085,7 @@ unique_ptr<parser::Node> Translator::translateRescue(pm_begin_node *parentBeginN
50855085 // For bare rescue clauses with no variable, create a <rescueTemp> variable
50865086 // Legacy parser uses zero-length location only when there are no exceptions AND no body,
50875087 // otherwise uses full keyword location
5088- auto rescueTemp = nextUniqueDesugarName (core::Names::rescueTemp ());
5088+ auto rescueTemp = nextUniqueName (core::Names::rescueTemp ());
50895089 auto syntheticVarLoc = (exceptionsArray == nullptr && rescueBody == nullptr )
50905090 ? rescueKeywordLoc.copyWithZeroLength ()
50915091 : rescueKeywordLoc;
@@ -5489,7 +5489,7 @@ core::NameRef Translator::translateConstantName(pm_constant_id_t constant_id) {
54895489 return ctx.state .enterNameUTF8 (parser.resolveConstant (constant_id));
54905490}
54915491
5492- core::NameRef Translator::nextUniqueDesugarName (core::NameRef original) {
5492+ core::NameRef Translator::nextUniqueName (core::NameRef original) {
54935493 ENFORCE (directlyDesugar, " This shouldn't be called if we're not directly desugaring." );
54945494 return ctx.state .freshNameUnique (core::UniqueNameKind::Desugar, original, ++uniqueCounter);
54955495}
0 commit comments