Skip to content

Commit 621587d

Browse files
committed
khepri_path, khepri_tree: Fix a few specs' return value
[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.
1 parent 9701b09 commit 621587d

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

src/khepri_path.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,9 @@ abspath([_ | _] = RelativePath, BasePath) ->
625625
abspath([] = PathToRoot, _) ->
626626
PathToRoot.
627627

628-
-spec realpath(Path) -> Path when
629-
Path :: native_pattern().
628+
-spec realpath(Path) -> NewPath when
629+
Path :: native_pattern(),
630+
NewPath :: native_pattern().
630631

631632
realpath(Path) ->
632633
realpath(Path, []).

src/khepri_tree.erl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,10 @@ squash_version_bumps_after_keep_while(
321321
%% Keep-while functions.
322322
%% -------------------------------------------------------------------
323323

324-
-spec to_absolute_keep_while(BasePath, KeepWhile) -> KeepWhile when
324+
-spec to_absolute_keep_while(BasePath, KeepWhile) -> AbsKeepWhile when
325325
BasePath :: khepri_path:native_path(),
326-
KeepWhile :: khepri_condition:native_keep_while().
326+
KeepWhile :: khepri_condition:native_keep_while(),
327+
AbsKeepWhile :: khepri_condition:native_keep_while().
327328
%% @private
328329

329330
to_absolute_keep_while(BasePath, KeepWhile) ->
@@ -395,11 +396,11 @@ update_keep_while_conds(Tree, Watcher, KeepWhile) ->
395396
KeepWhileConds1 = KeepWhileConds#{Watcher => AbsKeepWhile},
396397
Tree1#tree{keep_while_conds = KeepWhileConds1}.
397398

398-
-spec update_keep_while_conds_revidx(Tree, Watcher, KeepWhile) ->
399-
Tree when
399+
-spec update_keep_while_conds_revidx(Tree, Watcher, KeepWhile) -> NewTree when
400400
Tree :: tree(),
401401
Watcher :: khepri_path:native_path(),
402-
KeepWhile :: khepri_condition:native_keep_while().
402+
KeepWhile :: khepri_condition:native_keep_while(),
403+
NewTree :: tree().
403404

404405
update_keep_while_conds_revidx(
405406
#tree{keep_while_conds_revidx = KeepWhileCondsRevIdx} = Tree,

0 commit comments

Comments
 (0)