18577, "bmcdonald3", "Should the compiler always generate hash functions for records?", "2021-10-13T23:25:02Z"
My understanding is that currently the compiler generates a hash function for each record and this is done by hashing all of its fields and then combining those hashes together. This can cause the compiler-generated hash to not work in certain cases and cause the generated error to be difficult to decipher , such as when one of the fields is an
extern type. It seems reasonable to either generate better error messages when the generated hash does not work or just not generate the hash function at all if a hash function does not exist on one of the record fields.
The following code generates this error:
error: unresolved call '__mpz_struct.hash()', which seems strange since, to the user, it looks like we are trying to hash
bigint and they would have no idea what
__mpz_struct is or why it isn't working.
use BigInteger; var D: domain(bigint);
Do not generate a compiler hash function if the record contains external types or is non-POD. For the case listed above, this would mean that the error would look something like:
error unresolved call 'bigint.hash()', instead of saying one of the fields hash function isn't defined. This would make it easier to decipher that defining a
bigint.hash() would fix this issue.