This allows us to properly catch the 'is defined' and 'is undefined' checks and return the correct boolean result. Fixes #11892