An implementation of Visual Basic that is built into Microsoft products.
Thanks for sharing your detailed analysis.
From your findings, the issue happens because the same variable is passed to two different parameters. After the update, both parameters appear to share the same reference. So when the Optional parameter resets to its default value, it also affects the original variable. Using a separate variable, as you have done, is the correct way to avoid this issue.
Since this behavior is not clearly documented, we recommend reporting it to the product team through the https://developercommunity.microsoft.com/
so, they can review and clarify this behavior.
If you found this information useful, kindly mark this as "Accept Answer" so that others facing similar issues can easily find the solution. We are closing this thread for now. If you encounter any further issues, please feel free to raise a new thread.