unison icon indicating copy to clipboard operation
unison copied to clipboard

Unison stores local variable names in the serialized representation of definitions

Open anovstrup opened this issue 6 years ago • 6 comments

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.

anovstrup avatar Dec 13 '19 17:12 anovstrup

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.

anovstrup avatar Dec 13 '19 17:12 anovstrup

Not a bad idea.

aryairani avatar Dec 15 '19 16:12 aryairani

@runarorama @pchiusano Do you feel like messing with this for v2?

aryairani avatar May 24 '20 00:05 aryairani

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)

pchiusano avatar May 24 '20 14:05 pchiusano

UX notes from the community: this is a papercut that does occur with some frequency.

rlmark avatar Dec 03 '24 23:12 rlmark

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.

rlmark avatar Aug 13 '25 16:08 rlmark