Skip to content

Compact inferred functions#15371

Closed
gldubc wants to merge 1 commit into
elixir-lang:mainfrom
gldubc:fix-inference
Closed

Compact inferred functions#15371
gldubc wants to merge 1 commit into
elixir-lang:mainfrom
gldubc:fix-inference

Conversation

@gldubc
Copy link
Copy Markdown
Member

@gldubc gldubc commented May 13, 2026

If we infer an intersection of function types using clauses, we compact the clauses which have the same return type (if possible, that is, if the domain can be unioned).

A domain can be unioned if:

  1. it's of arity 1
  2. it's of arity n > 2, and all the arguments are the same but one which differs (this one gets unioned then).

PS: those two cases are in the added tests.

@josevalim
Copy link
Copy Markdown
Member

I'd like to do this when we generate the function, instead of the descr, because it means we can optimize when we generate the signature, rather than when the function is captured.

@josevalim josevalim closed this in 5509b95 May 14, 2026
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