Everything returns $null if it doesn't exist, with the warning disabled. The point of the warning is to prevent you from using an identifier when it doesn't exist. However, I'm thinking this is just for debugging a script and that normal operation should be to use your scripts without that warning.
If you only run your own scripts, you could probably get away with leaving the warning enabled. But as you saw, you may have to use different approaches. I don't believe this is a bug.