Make duplicate object definitions an error.

Fixes #3638