Skip to content

Recursive type checker#1289

Open
cormacrelf wants to merge 10 commits into
facebook:mainfrom
cormacrelf:recursive-type-checker
Open

Recursive type checker#1289
cormacrelf wants to merge 10 commits into
facebook:mainfrom
cormacrelf:recursive-type-checker

Conversation

@cormacrelf
Copy link
Copy Markdown
Contributor

@cormacrelf cormacrelf commented Apr 10, 2026

Just this part of #1148. It is described most fully in the doc comment in typecheck.rs. As a reminder, the big impact is that we now typecheck top level assignments and function calls.

OSS buck is not actually building right now (#1280). But with some dumb fixes to those issues applied on top, this builds.

I added one extra change 'Fix TyUser not forwarding bin_op' so that the prelude typechecks. i.e. buck2 starlark typecheck prelude/**/*.bzl. There were only failures because these things always appeared in top-level bindings e.g. Blah = provider(fields = ... RunInfo | None, ... ). Under real world usage I don't know, run it on your systems and see what shakes out.

Attn @Wilfred who wanted this separate in 1148.

We will later use this to disallow duplicate type annotations.
That's why we include error_span, etc.
For use in BindingsCollect.
Previously, we gathered and solved bindings for every top-level def,
and not for a module's root bindings.

This was a deliberate limitation for typechecker performance reasons,
introduced in D48752028/D48752027 back in 2023.

This completes the work described in those diffs, which said ideally:

1. typecheck top-level assignments
2. then evaluate defs

This does one better and typechecks even nested defs individually. This achieves the
goal of reducing the iterations needed in solve_bindings by passing the
smallest possible quantity of bindings to solve_bindings at any one time.
This makes the prelude type-check again after the recursive type checker
was introduced. Errors were e.g 'RunInfo | None' not finding binop |.
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 10, 2026
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Apr 10, 2026

@facebook-github-bot has imported this pull request. If you are a Meta employee, you can view this in D100318302. (Because this pull request was imported automatically, there will not be any future comments.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant