Use assertion instead of exception for invalid expressions