Qualified declarations resolve namespace too eagerly.
typeswitch-dev opened this issue · 0 comments
Type-qualified declarations, e.g.
def(Int.show, ..., ...)
require having the type name available right away. If the type is unknown, whether because it is defined later in the file, or in an imported module that hasn't yet been processed (e.g. if the modules depend on each other), then this causes an unrecoverable error in the compiler. The issue is that the compiler needs to know where to put the definition, i.e. what qualified name should it give to the word being defined.
It causes issues like a package that only compiles correctly if its modules are imported in a certain order. (This happens right now between mirth.type
and mirth.data
.)
To fix it, we should defer the resolution of the type name until we must ... or in general, defer the resolution of namespaces until they are needed. If the namespace is still unresolvable by then, it's an actual error.