`block.type === 'Program'` is missed.
So, check `this.type === 'global' || this.type === 'function'`.