Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qualified declarations resolve namespace too eagerly. #268

Closed
typeswitch-dev opened this issue Apr 28, 2024 · 0 comments
Closed

Qualified declarations resolve namespace too eagerly. #268

typeswitch-dev opened this issue Apr 28, 2024 · 0 comments
Labels
bug Something isn't working compiler Compiler internals.

Comments

@typeswitch-dev
Copy link
Contributor

typeswitch-dev commented Apr 28, 2024

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.

@typeswitch-dev typeswitch-dev changed the title Type qualified declaration too eager. Type qualified declaration resolve namespace too eagerly. Apr 28, 2024
@typeswitch-dev typeswitch-dev added bug Something isn't working compiler Compiler internals. labels Apr 28, 2024
@typeswitch-dev typeswitch-dev changed the title Type qualified declaration resolve namespace too eagerly. Type qualified declarations resolve namespace too eagerly. Apr 28, 2024
@typeswitch-dev typeswitch-dev changed the title Type qualified declarations resolve namespace too eagerly. Qualified declarations resolve namespace too eagerly. Apr 28, 2024
typeswitch-dev added a commit that referenced this issue May 19, 2024
Defers namespace resolution for word definitions, aliases, externals,
and table fields. This fixes issue #268
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler Compiler internals.
Projects
None yet
Development

No branches or pull requests

1 participant