Skip to content

Simplify differences#15153

Merged
josevalim merged 4 commits intomainfrom
jv-simpler-diffs
Mar 8, 2026
Merged

Simplify differences#15153
josevalim merged 4 commits intomainfrom
jv-simpler-diffs

Conversation

@josevalim
Copy link
Copy Markdown
Member

@josevalim josevalim commented Mar 8, 2026

The previous implementation was incorrectly nesting differences.
So if we had four clauses, the four clause was computing the type as:

clause4 - (clause3 - clause2 - clause1) - (clause2 - clause1) - clause1

While it should have been:

clause4 - clause3 - clause2 - clause1

This means that instead of n differences, we had an arithmetic progression of n * (n + 1) / 2 clauses. The benefit is that we have now optimized the hell of the type system, but we now need to reassess which optimizations we want to keep long term.

  • Revisit refine_guard_var
  • Revisit map difference
  • Revisit tuple elimination

Closes #15129, closes #15149.

@josevalim
Copy link
Copy Markdown
Member Author

I will revisit map difference and tuple elimation in future commits/PRs.

@josevalim josevalim merged commit b98d823 into main Mar 8, 2026
26 checks passed
@josevalim josevalim deleted the jv-simpler-diffs branch March 8, 2026 22:02
@josevalim
Copy link
Copy Markdown
Member Author

💚 💙 💜 💛 ❤️

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.

Slow type-checking Compiler hangs with exponential time when function clauses pattern match on different map key sets

1 participant