Some checking for duplicate fields. No constraints yet.

Also added a test case where infer should fail when we do have constraints.