Skip to content

Conversation

@katafrakt
Copy link
Contributor

This PR add support for function calls using __MODULE__ special form, like:

___MODULE__.function1()

It was not working, because Forge parses __MODULE__ as {:var, ~c"__MODULE__"}, not as an atom/module. Because of that, a special handling case just for {:var, ~c"__MODULE__"} needed to be added.

Recognizing __MODULE__ as :var, while might be semantically incorrect, does not seem to be a problem in scope of definition finding.

The PR also adds an additional test, making sure that a popular formula of using alias __MODULE__ in the module is correctly handled by the Engine.

…MODULE__

This wasn't working, as __MODULE__ is recognized as :var, not as
:module in AST. What was needed is to add a special handling of it in
`expand_alias` function.

Recognizing __MODULE__ as :var, while semantically incorrect, does not
seem to be a problem in scope of definition finding. It's not strictly a
module either, so to be super-correct, we would need to add a special
handling just for it.
Copy link
Collaborator

@doorgan doorgan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The fix makes sense to me. I tried a variety of __MODULE__ usages and everything works.

@doorgan doorgan changed the title feat(engine): support go to definition when function is called via __MODULE__ fix(engine): support go to definition when function is called via __MODULE__ Dec 19, 2025
@doorgan doorgan merged commit b1d5e17 into elixir-lang:main Dec 19, 2025
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants