I'm working on canonicalization and I'm thinking about how Symbol
gets used in various places. It seems like although they're globally unique, we don't actually rely on that property in practice - e.g. we keep track of a scope in type checking and code gen so that we can change the meaning of a given Symbol
as we traverse various scopes
it would definitely simplify things and reduce memory usage if we could drop the property that symbols need to be globally unique and instead have them be essentially per-module string interning IDs and that's it
so I'm wondering - does anyone know of any places in the compiler where we rely on symbols being globally unique?
Would a symbol imported from another module not cause a potential clash in this system?
oh those will already need to be translated
because of caching - if we want to cache the canonical IR for a given module on disk, then it can't have (our current concept of) ModuleId
in any of its identifiers, because those can change depending on which modules are being compiled, random chance involving when threads happen to finish work, etc.
so I guess I shouldn't have said globally unique, but rather unique within the module :big_smile:
Last updated: Jul 06 2025 at 12:14 UTC