Skip to content

Improve send return type inference#15643

Closed
lukaszsamson wants to merge 1 commit into
elixir-lang:mainfrom
lukaszsamson:lukaszsamson-send-return-type
Closed

Improve send return type inference#15643
lukaszsamson wants to merge 1 commit into
elixir-lang:mainfrom
lukaszsamson:lukaszsamson-send-return-type

Conversation

@lukaszsamson

@lukaszsamson lukaszsamson commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

:erlang.send/2 returns the message term verbatim, but the type checker previously treated it as dynamic(). This made unreachable clauses after send/2 look possible and lost precision for every Kernel.send/2 call because it inlines to :erlang.send/2.

Summary

  • Add a special :erlang.send/2 remote apply path that returns the computed message operand type.
  • Cover Kernel.send/2 identity behavior in module type tests.

Tests

  • make test_stdlib TEST_FILES=module/types/expr_test.exs
  • make test_formatted

Teach the type checker that Kernel.send/2 returns the message operand and add a typed signature for :erlang.send/3 status returns.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@josevalim

Copy link
Copy Markdown
Member

👍 we can definitely make it more precise. But let's type only send/2 for now.

@lukaszsamson

Copy link
Copy Markdown
Contributor Author

👍 we can definitely make it more precise. But let's type only send/2 for now.

Addressed in a new one #15644

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