@@ -2307,25 +2307,28 @@ unique_ptr<parser::Node> Translator::translate(pm_node_t *node, bool preserveCon
23072307 auto sign = value[0 ];
23082308 bool hasSign = (sign == ' +' || sign == ' -' );
23092309
2310+ auto numberLoc = location;
23102311 if (hasSign) {
23112312 value.remove_prefix (1 ); // Remove the sign
2313+
2314+ numberLoc = core::LocOffsets{location.beginPos () + 1 , location.endPos ()};
23122315 }
23132316
23142317 // Create the desugared Complex call: `Kernel.Complex(0, unsigned_value)`
2315- auto kernel = MK::Constant (location , core::Symbols::Kernel ());
2318+ auto kernel = MK::Constant (numberLoc , core::Symbols::Kernel ());
23162319 core::NameRef complexName = core::Names::Constants::Complex ().dataCnst (ctx)->original ;
23172320 core::NameRef valueName = ctx.state .enterNameUTF8 (value);
2318- auto complexCall = MK::Send2 (location , move (kernel), complexName, location .copyWithZeroLength (),
2319- MK::Int (location , 0 ), MK::String (location , valueName));
2321+ auto complexCall = MK::Send2 (numberLoc , move (kernel), complexName, numberLoc .copyWithZeroLength (),
2322+ MK::Int (numberLoc , 0 ), MK::String (numberLoc , valueName));
23202323
23212324 // If there was a sign, wrap in unary operation
23222325 // E.g. desugar `+42` to `42.+()`
23232326 if (hasSign) {
2324- auto complexNode = make_unique<parser::Complex>(location , string (value));
2327+ auto complexNode = make_unique<parser::Complex>(numberLoc , string (value));
23252328 core::NameRef unaryOp = (sign == ' -' ) ? core::Names::unaryMinus () : core::Names::unaryPlus ();
23262329
23272330 auto unarySend = MK::Send0 (location, move (complexCall), unaryOp,
2328- core::LocOffsets{location.beginLoc , location .beginLoc + 1 });
2331+ core::LocOffsets{location.beginLoc , numberLoc .beginLoc });
23292332
23302333 return make_node_with_expr<parser::Send>(move (unarySend), location, move (complexNode), unaryOp,
23312334 core::LocOffsets{location.beginLoc , location.beginLoc + 1 },
0 commit comments