So for every variant case, you generate a unique integer tag, different from a tag of any other variant cases ever compiled in the future or the past? OCaml, for example, tries to do exactly that by hashing the names of cases in the polymorphic variants, and in case of hash collisions it just gives up [0].
[0] https://schu.be/til-ocaml-polymorphic-variant-hash-collision...