Add a check for multiple definitions of the same dependency.

An attempted fix for #1107 (doesn't actually work).