Closed adam-antonik closed 4 years ago
Oh that's a good one! I had accounted for this in one place, but obviously not deeply enough. You're right, we need to reject the construction of record types with duplicate field names entirely (however they're arrived at). It should never get to the stage where a user sees {a:int,a:int}
.
OK, I fixed this here: https://github.com/Morgan-Stanley/hobbes/pull/360
And I added some tests to verify it. Now it won't be possible to construct record or variant types with duplicate names, no matter how roundabout the process of deciding those names is.
Thanks for pointing this out.
Thanks adam, I've got this fix merged to master and added some tests to verify that such types (records and variants with duplicate field/constructor names) are rejected.
This example segfaults straightaway when called, but a slightly more convoluted version can actually get us an object with duplicated fields. Would it be possible for this to be caught as a unification error in type-checking?