-
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
Optionally infer types of literals and other constructs #54
Conversation
Perhaps options can be used to evaluate different approaches? With this enabled, we can catch the type error in the example in #26 (comment) f() ->
V = [1, 2],
g(V).
-spec g(integer()) -> any().
g(Int) -> Int + 1. A similar option could be used to control how short-circuit expressions are handled... |
Neat! What's your suggestion regarding testing? As you said, some code will fail/pass type checking depending on this option's value. Two new subdirectories? |
I don't know @Zalastax. I think unit tests using code in strings, as in the typechecker_tests suite, is better than the should_fail/pass ones. |
I don't agree that strings are better - they lack syntax highlighting. |
A new option `infer` is added. (`--infer` and `--no-infer` for the CLI.) With this option enabled, types of literals, list cons, list comprehensions, tuples and bit syntax expression are propagated in addition to the types from the specs of functions.
Maybe put configuration options inside the source files in an attribute or as a special comment? |
You mean |
great job @zuiderkwast, Im very positive about this option :) (hope I will have time to review sooner or later) regarding testing I think the should_pass/fail are nice as smoke tests but a bit limited (for example you cannot test if there are 1 or more errors in a should_fail module). the typechecker_tests-style tests need less context, can reach edge cases easier, or eg can also test specific errors (when gradualizer will support returning error terms) regarding module attributes, I think in real use the option should be per project (eg in rebar.config) and not per module - but for testing a module attribute can be a nice idea. |
I don't have time to do a proper review right now, but I really like the idea here, @zuiderkwast! If I understand correctly, you don't propagate the type of lambdas and maps. I think they should probably be added, though it would be fine if that was a separate commit. In my mind the |
Good point that maps and funs should be inferred as well. Let's add that later! |
A new option `infer` is added. (`--infer` and `--no-infer` for the CLI.) With this option enabled, types of literals, list cons, list comprehensions, tuples and bit syntax expression are inferred and propagated in addition to the types from the specs of functions.
A new option
infer
is added. (--infer
and--no-infer
for the CLI.)With this option enabled, types of literals, list cons, list comprehensions,
tuples and bit syntax expression are propagated in addition to the types
from the specs of functions.