Closed Aflynn50 closed 7 months ago
This bugfix has been changed to use the approach detailed above. The map typeMemberPresent
is now indexed by a string representation of the type member. This avoids the need to replace the mapKey methods with value receivers which would introduce a bad smell (even if there was a justification) into the code.
Add a test for duplicate map keys and check for duplicates using equality of the string representation of the
typeMember
rather than equality of the pointer.In #75 a bug was unwittingly introduced.
mapKey
andstructField
are both structs that implemented thetypeMember
interface. #75 change it so their a pointer to them implemented the interface so that the types could be passed around by reference rather than by value. The only problem is, that the maptypeMemberPresent
is indexed bytypeMembers
. This was therefore now indexed by pointers to structs rather than the structs themselves.An error is thrown if two of the same
typeMember
appear in the outputs as this could create ambiguity. The test for this error still passed because in the case ofstructField
s if two fields of the same struct are present then both will have the same pointer (as they are added fromtagToField
instructInfo
which was amap[string]*structField
. This is not the case for maps however.