-
Notifications
You must be signed in to change notification settings - Fork 19
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
Add compiler warnings #346
Conversation
@hanssv @radrow I'm looking for a way to properly report the warnings. Right now, the warnings are all stored in an ets_table called Do you think I should keep forwarding the warnings as strings upwards until they get to the |
I think that warnings should be returned as renderable structures as a result of the compilation/infer function |
Yes, keeping them in some warning structure (similar to the errors) and passing them upwards sounds like the best alternative. Then we can present them, or return them (or ignore them) according to options I guess. |
Add include_type annotation to position Add warning for unused includes Add warning for unused stateful annotation Add warning for unused functions Add warning for shadowed variables Add division by zero warning Add warning for negative spends Add warning for unused variables Add warning for unused parameters Change the ets table type to set for unused vars Add warning for unused type defs Move unused variables warning to the top level Temporarily disable unused functions warnings Add all kinds of warnings to a single ets table Enable warnings separately through options Use when_option instead of enabled_warnings Turn warnings into type errors with warn_error option Enable warning package warn_all Re-enable unused functions warnings Report warnings as type errors in a separate function Make unused_function a recognized warning Report warnings as a result of compilation Fix tests and error for unknown warnings options Fix dialyzer warnings Do not show warning for variables called "_" Move warnings handling into a separate module Do not show warning for unused public functions in namespaces Add src file name to unused include warning Mark public functions in namespaces as used Add tests for added warnings Add warning for unused return value Add test for turning warnings into type errors
For negative spends and division by zero, the warning will only show when using a literal.
I think it won't be very difficult to add warning for the second case |
I guess if the compiler have a optimization phase to evaluate that and you run the warning check in a step/phase after it it would be covered by case 1 |
there could be a second pass of warning check after additional constant propagation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Looks good!
Would be nice to reflect it in the cli and http interface too |
@nikita-fuchs would be great to see it working in aestudio :) |
dayumn, thanks for bringing this up. |
Currently added warnings:
stateful
annotationsnon-exhaustive patterns(this will be tricky and should better be done in a separate PR)Currently supported options:
Things that still need to be done:
Testing: