Unison stores local variable names in the serialized representation of definitions
Although local variable names are normalized away when computing the hash of a definition, they are currently still stored in the serialized representation of the definition. As a result, renaming a local variable is an unnecessarily painful experience.
This problem could be resolved by storing local variable names as metadata and replacing them with De Bruijn indexes in the serialized form.
More generally, it may be beneficial if all normalizations applied during hashing were also applied to the abstract syntax tree prior to serialization, with the normalization "operations" stored as metadata so that they could be reversed upon deserialization. Doing this would cleanly separate normalization from hashing (simplifying the hashing logic) and would ensure that the representation that is hashed is identical to the representation that is serialized for two equivalent definitions. The latter property could make it less costly to verify that a serialized definition hashes to a given value (e.g., after a definition for the hash is requested over the network). This more general solution may have deeper ramifications and would require larger changes; therefore, it's probably best undertaken in a separate issue after some discussion/design.
Not a bad idea.
@runarorama @pchiusano Do you feel like messing with this for v2?
Doesn’t seem super pressing to me but maybe we could design the format to be more extensible, so like just the term serialization could be replaced piecemeal. (Like just a version number at the start of each serialized term)
UX notes from the community: this is a papercut that does occur with some frequency.
For UX papercut record-keeping, this issue was discussed on 8-12-25. With the idea of
update.force suggested by a community member as a potential option.