This looks sort of related to
I found that if you add a default of undef to the $gid param on account::base then it's correctly undef.
Nick Lewis Thanks for responding. About a month ago I ended up doing exactly what you suggested but neglected to come back and update this ticket. It works and that's good enough for me. Thanks again!
Reopening as this still seems like incorrect behavior, despite having a workaround.
We'll need to get a reproduction case to see if the variable shadowing or lack thereof is an issue.
This hasn't been updated in 2+ years, I'm going to close this. Please reopen if it's still an issue.