-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Require all functions in src/typechecker.erl to have specs #499
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…return_type_should_pass.erl Based on `import_beam_files/2` calling itself: -spec import_beam_files([file:filename() | binary()], state()) -> {ok, state()} | gradualizer_file_utils:parsed_file_error(). import_beam_files([File | Files], State) -> case gradualizer_file_utils:get_forms_from_beam(File) of {ok, Forms} -> {attribute, _, module, Module} = lists:keyfind(module, 3, Forms), import_beam_files(Files, import_absform(Module, Forms, State)); Error = {Status, _} when (Status /= ok) -> Error end; import_beam_files([], St) -> {ok, St}.
This raises hits on line 1245 of Cover output from 0 to 1: 1233 -spec expect_tuple_union(Tys, [Tys], constraints:t(), any | no_any, non_neg_integer(), env()) -> R when 1234 Tys :: [type()], 1235 R :: {[Tys], constraints:t()}. 1236 expect_tuple_union([Ty|Tys], AccTy, AccCs, Any, N, Env) -> 1237 27 case expect_tuple_type(Ty, N, Env) of 1238 {type_error, _} -> 1239 9 expect_tuple_union(Tys, AccTy, AccCs, Any, N, Env); 1240 any -> 1241 1 expect_tuple_union(Tys, AccTy, AccCs, any, N, Env); 1242 {elem_ty, TTy, Cs} -> 1243 16 expect_tuple_union(Tys, [TTy | AccTy], constraints:combine(Cs, AccCs), Any, N, Env); 1244 {elem_tys, TTys, Cs} -> 1245 1 expect_tuple_union(Tys, TTys ++ AccTy, constraints:combine(Cs, AccCs), Any, N, Env) 1246 end; 1247 expect_tuple_union([], AccTy, AccCs, any, N, _Env) -> 1248 1 {[ lists:duplicate(N, type(any)) | AccTy], AccCs}; 1249 expect_tuple_union([], AccTy, AccCs, _NoAny, _N, _Env) -> 1250 12 {AccTy, AccCs}.
erszcz
force-pushed
the
raise-errors-on-missing-specs
branch
from
December 28, 2022 16:13
0ad0bbb
to
43e5295
Compare
erszcz
changed the title
Raise compile errors on missing specs in src/typechecker.erl
Require all functions in src/typechecker.erl to have specs
Dec 28, 2022
This fixes quite a few self-check errors, so I'm merging it, but I'm still happy with any reviews to come. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This significantly raises the bar on self-check consistency by requiring ALL functions in the type checker to have specs. It uncovered a number of consistency issues, but most of them could be solved. Most importantly, though, it documents the interfaces between various parts of the type checker and eases discoverability.
Done in this PR:
warn_missing_spec_all
insrc/typechecker.erl
constraints:constraints()
toconstraints:t()
for brevityThis PR is also a good example of dog-fooding.