Wax_conversion.NamespaceSourceA namespace manages a set of unique names, avoiding collisions with reserved keywords and previously allocated names.
The Wax bare-word keywords (the `Regular reserved set). Kept in sync with the lexer by the keyword-consistency test; reused for editor keyword completion so it does not drift.
Create a new namespace. kind determines the set of reserved words (default `Regular):
`Regular: Standard reserved keywords (e.g., "if", "loop").`Label: No reserved words (empty).`Type: Reserved keywords plus abstract heap types (e.g., "func", "any").dup t returns a copy of the namespace t. Changes to the new namespace will not affect t.
add t name registers name in the namespace t. If name is already taken or reserved, a unique suffix is appended (e.g., "name_1", "name_2"). Returns the unique name that was actually registered.
type outcome = | Availablename was free and registered as-is.
| Renamed of {reserved : bool;previous : Wax_utils.Ast.location option;}name was taken and a suffix was appended. reserved is true when the requested name is a reserved word, false when it collided with another registered name. previous is the location the colliding name was first claimed from, when one was recorded (always None for a reserved word).
Like add, but also reports whether the name was renamed and, if so, whether the collision was with a reserved word and where the colliding name was previously claimed. loc records this name's source location, so a later collision with it can point back here.
is_reserved t name is true when name is one of the namespace's reserved words (a Wax keyword), independent of any names already added. Used to skip an inferred name (an export or import name) that is a keyword, since the suffixed rename it would force reads worse than a generated default.