Don't `yield` on non generator functions. Fixes #3908.

Additionally, simplified match logic, replaced 3*`==` by `in`.