Nicer errors for attribute assignments

Fixes #107