Skip to content

Instantly share code, notes, and snippets.

@ghiculescu
Last active October 10, 2019 19:13
Show Gist options
  • Save ghiculescu/393c4c40b645c19fd95ec4f7e4241bc8 to your computer and use it in GitHub Desktop.
Save ghiculescu/393c4c40b645c19fd95ec4f7e4241bc8 to your computer and use it in GitHub Desktop.

srb rbi suggest-typed internally runs srb tc --typed=strict --error-white-list=7022 --suggest-typed -a

--error-white-list means "only output errors of this kind", and 7022 is the error that is used to suggest a type. therefore, this runs sorbet at typed: strict across the board, and then outputs errors with type suggestions where appropriate.

THE PROBLEM is that when we run this on our (big) codebase, a bunch of files get downgraded to typed: ignore. but if we run srb tc on the same codebase, with higher sigils (eg. typed: true) on those files, there's no errors.

the type sorbet suggests is one level lower than the file's current min error level: https://github.com/sorbet/sorbet/blob/c33b7e2e41657b482a631e2edb931258995406bc/main/realmain.cc#L525

errors have a minLevel that comes from their what, which is an ErrorClass: https://github.com/sorbet/sorbet/blob/09fc62528d3b25357e297b594e699ab096d8b12d/core/Error.h#L132.

error classes are listed in https://github.com/sorbet/sorbet/tree/2275752e51604acfb79b30a0a96debc996c089d9/core/errors. there's a lot.

this all means that if sorbet is dropping something to typed: ignore, the file would have previously had an error of StrictLevel::False on it. but that also means that if we put typed: true on the file it should fail typechecking?

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