Lyricdev
GitHub

LYR-MIG0305

a hash that returned an int

hint · spec 14-cli

A note of lyric fix --from-4: hash() returned an int in Lyric 4; Lyric 5's hash writes the value into a hasher, and the migration rewrites the method.

Explanation

Lyric 4's Hashable<T> had hash(): int, built with combineHash; Lyric 5's Hashable has hash<H :: [Hasher]>(&h: H), which writes the value into the hasher. The migration writes the signature anew; a returned combineHash chain over x.hash() becomes each x.hash(&h); in its order, any other returned value h.writeInt(value);. The import of combineHash names Hasher instead.

The hash values differ from Lyric 4's, and a program that stored them stores others. Where the method hashes every field the way equals compares them, leave it out: Lyric 5 writes it.

Said by hand: a hash computed from other hashes in another shape, and a call of hash() that used the int — make a hasher and read its value.

Example

proposal[LYR-MIG0305] main.lyr:10:8: 'Key.hash' returned an int; Lyric 5's writes the value into a hasher, so the hashes differ from Lyric 4's — where it hashes every field the way 'equals' compares them, leave the method out: Lyric 5 writes it