erlang: replace unbound vars in specs with wildcards (_) (fixes #20)
#38
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.
Fixes #20
Change
Rolling back e916333. + Changing the logic of handling type variables in specs:
If a generated/translated spec has a type variable which is used exactly once (
erl_lintcalls such variables "unbound variables"), such a variable is replaced with the wildcard type variable (_). This makeserlc/erl_linthappy about generated code.Snapshot tests are updated accordingly.
Subtlety
This new logic doesn't try to distinguish "original" (but also unbound for
erlc) OCaml type variables and inferred type variables: if a type variable is unbound it will be replaced by_anyway.This makes this example less idiomatic:
Before:
After:
Possible improvement(s)
_, eg the unbound type variable_Xis totally fine forerl_lintand falls into the category "I don't care".where_is) and to not replace them with_.erlang/src/erl_ast_helper.ml- I did not read many parts of the project in detail, - so my code is likely not of the same style as the rest of the project.Thanks for a really cool and interesting project!