Wow those moves are perfect for this Mew!

Hate the split hairs, but this isn't entirely accurate. The actual bug that allows this glitch is called a race condition. Gameboys had a limited amount of memory compared to modern consoles. To get around this, the Pokemon developers reused memory addresses to store variables such as HP, Attack, and the important one for this glitch, Special.

When a trainer engages the player, the values for the trainer's Pokemon are stored in memory, along with another variable indicating that a battle should be taking place. The race condition occurs when the player presses start mid-step right before entering the trainer's sight when the trainer is off-screen the step prior. Because all trainer sprites first render as looking north, the player gets the menu before being engaged.

The player teleports away, but the game still has stored in memory that a battle should take place in that area. So upon returning to the area, the game generates a wild Pokemon encounter. The Pokemon that appears is based on its index value, which is normally randomly generated from a predefined set of numbers for that area. The reason Mew appears is because the location in memory that tells the game which Pokemon to generate is the same location that stores the Special stat of the last Pokemon in the last battled trainer's party.

Using this glitch, you can catch every Pokemon in the game.

/r/gaming Thread Parent Link - i.redd.it