hylo
hylo copied to clipboard
Demangler is broken
This symbols can't be demangled: R0U3IntcDaTR2ZZF04copy0lTtT14selfrT1K20K2
. It corresponds to the definition of Int.copy
, which is defined in a conformance declaration in Int.hylo
from the core library.
The issue is due to an asymmetry between the mangling and demangling algorithms. The former is updating the symbol lookup table before scopes are mangled, in order to avoid infinite recursions. Other symbols are added to the symbol lookup table after being mangled. However, the demangling algorithm always assume symbols are added to the table after having been mangled.
I think we have to change the mangling algorithm. We need to find a way to
- avoid infinite recursion; and
- always insert mangled symbols to the lookup table after they have been mangled.
I am getting the sense that we may have to divide and conquer: recursively visit the entity/type to mangle and pick identifiers for all components and then write the mangled representation of each component to the stream.