This phenomenon has confused me a long time. Consider the following package example,
BeginPackage["temp`"];
test;
test2;
Begin["Private"];
f[x_]:=
test_:>{x,test};
f2[x_]:=
test2_:>{test2};
End[];
EndPackage[];
where test2 is for comparison.
Then in notebook evaluate the following test code with a fresh kernel,
<<temp`
Names["temp`*"]
??test$
??temp`test2$
It's weird that the temporary symbol test$ leaks into the public context temp` .
Notice that:
the leaked temporary symbol must have the same name as the public one;
the local symbol
xin the definition offis necessary to repeat this behaviour.
Is this a bug?

f, but I can't explain it. Other than it's because of thexin the RHS of theRuleDelayed[]. – Michael E2 Jun 20 '23 at 19:46temp`Private`f[3]should ever be called. – Michael E2 Jun 20 '23 at 21:32