Description
The documentation of Ident.rename
function states that it returns a identifier with a fresh stamp.
Lines 37 to 40 in e72d835
However it is not the case because when compiling a module we use a certain stamp generator and another one is used when compiling another module. Thus we can have stamp collisions between different modules.
For example when modifying the function rename in ident.ml to
let rename = function
| Local { name; stamp = _ }
| Scoped { name; stamp; scope = _ } ->
incr currentstamp;
if name = "H" then Format.printf "H(%i -> %i)\n" stamp !currentstamp;
Local { name; stamp = !currentstamp }
| id ->
Misc.fatal_errorf "Ident.rename %s" (name id)
We clearly see examples when compiling the whole compiler of modules being compiled with rename
reducing the stamp of a identifier. Thus showing that the invariant for generating a fresh stamp is broken.
Is the fact that the stamp is not fresh (even if the documentation says so) an accepted behavior or something uncontrolled ?
PS : As a consequence, during the stap OCAMLOPT ocamldoc/odoc_ast.cmx
of compilation the comparison function between identifiers is called on 2 identifiers with the same stamp and different names.