elixir-lsp / elixir-lsp/elixir_sense

Make expansion AST pass to be typed-based

Open
#297 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Elixir
Stars
340
Forks
43
PR merge metrics
No merged PRs in 30d

Description

Today, the pass returns the expanded AST. However, I don't think `elixir_sense` actually needs the AST. Instead, it must pass type information around. My suggestion is for it to track at first:

* `{:struct, name}`
* `{:atom, name}`
* `dynamic`

Dynamic can be the default type for anything you don't know what the return is.

This also means the current implementation can be simplified:

1. There is no need to build the ast for `quote`
2. There is no need to traverse the right side of `::` in binaries (the implementation can be much simpler)

Open questions and Elixir improvements:

1. Do you need to port Elixir's rewrite rules? If so, we should expose this in Elixir itself
2. Can we support Record, Protocol, ExUnit.Case without adding special rules? Carrying type information, especially atoms, may actually help here. Should we improve something in Elixir to make this possible?
3. There may be other complex areas we should ask Elixir to expose. If so, which?

These topics have been first brought up here: https://github.com/elixir-lsp/elixir_sense/pull/293

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.