Add invariant for a mixin not to be undefined.

Fixes #1302.