Fix Dialyzer warnings#341
Merged
Merged
Conversation
d48f769 to
7779211
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## v0.17.x #341 +/- ##
===========================================
+ Coverage 89.59% 89.62% +0.02%
===========================================
Files 22 22
Lines 3441 3450 +9
===========================================
+ Hits 3083 3092 +9
Misses 358 358
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
[Why] In `khepri_machine_v0`, it can only return a `tree_v0()` tree. This was reported by Dialyzer in Erlang/OTP 28.
…()` terms [Why] `khepri_tree:tree()` can be either a `tree_v0()` or a `tree_v1()` which are both opaque types. Therefore, they can't simply be compared with =:= because it violates the contract that a e.g. a `tree_v0()` can't be compared to a `tree_v1()` without knowing their internals. This was reported by Dialyzer in Erlang/OTP 28. [How] We move the assert to `khepri_tree` which defines these opaque types and thus has the right to compare them.
…` terms [Why] `khepri_machine:state()` can be either a `state_v0()` or a `state_v1()` which are both opaque types. Therefore, they can't simply be compared with =:= because it violates the contract that a e.g. a `state_v0()` can't be compared to a `state_v1()` without knowing their internals. This was reported by Dialyzer in Erlang/OTP 28. [How] We add an assert function to both `khepri_machine` and `khepri_machine_v0`. They can inspect their respective version of the state because they define it.
[Why] This helps Dialyzer give more accurate warnings.
[Why] There are several functions which use the same variable as an argument and as their return value in their spec. Semantically, this means that the argument is returned as is. Dialyzer doesn't enforce anything with that (yet). But this is still incorrect. So while working on several warnings, fix a few function specs. There are still other functions that are incorrect in the same way.
2899d34 to
c76adba
Compare
[Why]
Our `#tree{}` type has two versions which differ on the type of the
`keep_while_conds_revidx` field. We also defined two type, `tree_v0()`
and `tree_v1()` which finished to define the two versions.
This was fine up to and including Erlang/OTP 27. However with Erlang/OTP
28, Dialyzer complained that `update_keep_while_conds/3` would never
return.
This was caused by the new "nominal type" property of opaque types: if I
understand correclty, based on the type specs, we couldn't modify the
`#tree{}` record in `update_keep_while_conds/3` because the returned
`#tree{}` might not be a `tree_v0()` or a `tree_v1()`.
[How]
In the end, we couldn't use the #tree{} record directly to define the
`tree_v0()` and `tree_v1()` types. We have to use an intermediate type
that takes the type of the `keep_while_conds_revidx` field, then use
this intermediate type in the definition of `tree_v0()` and `tree_v1()`.
We remove the type of the `keep_while_conds_revidx` field in the record
because it breaks the compilation with Erlang/OTP 27.
c76adba to
8ecac17
Compare
This file contains hidden or 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
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 is a collection of fixes of warnings reported by Dialyzer in Erlang/OTP 28.
These are not reported on CI yet because we can’t test against Erlang/OTP 28 until a new release of Rebar is published with the fix to make it work on Windows (erlang/rebar3#2954).