Skip to content

Commit 62b789c

Browse files
committed
Don't report redundant optional arguments on functions annotated @live.
1 parent 77dd375 commit 62b789c

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

Changes.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# master
2+
- Don't report redundant optional arguments on functions annotated `@live`.
23

34
# 2.18.0
45
- Don't report unused optional arguments for functions annotated `@live` or `@genType`.

examples/deadcode/src/deadcode.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,10 +2277,6 @@ File References
22772277
Live Value +TestModuleAliases.+testInner2: 0 references () [0]
22782278
Live Value +TestModuleAliases.+testInner1Expanded: 0 references () [0]
22792279
Live Value +TestModuleAliases.+testInner1: 0 references () [0]
2280-
2281-
Warning Redundant Optional Argument
2282-
File "./TestOptArg.res", line 14, characters 0-66
2283-
optional argument x of function +liveSuppressesOptArgs is always supplied (1 calls)
22842280
Live Value +TestOptArg.+liveSuppressesOptArgs: 1 references (TestOptArg.res:16:8) [0]
22852281

22862282
Warning Unused Argument
@@ -4508,4 +4504,4 @@ File References
45084504
<-- line 96
45094505
type variant1Object = | @dead("variant1Object.R") R(payload)
45104506

4511-
Analysis reported 332 issues (Warning Dead Exception:1, Warning Dead Module:24, Warning Dead Type:88, Warning Dead Value:200, Warning Dead Value With Side Effects:2, Warning Redundant Optional Argument:6, Warning Unused Argument:11)
4507+
Analysis reported 331 issues (Warning Dead Exception:1, Warning Dead Module:24, Warning Dead Type:88, Warning Dead Value:200, Warning Dead Value With Side Effects:2, Warning Redundant Optional Argument:5, Warning Unused Argument:11)

src/DeadOptionalArgs.ml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -84,17 +84,18 @@ let forceDelayedItems () =
8484

8585
let check decl =
8686
match decl with
87-
| {declKind = Value {optionalArgs}} when active () ->
88-
if not (ProcessDeadAnnotations.isAnnotatedGenTypeOrLive decl.pos) then
89-
optionalArgs
90-
|> OptionalArgs.iterUnused (fun s ->
91-
Log_.info ~loc:(decl |> declGetLoc) ~name:"Warning Unused Argument"
92-
(fun ppf () ->
93-
Format.fprintf ppf
94-
"optional argument @{<info>%s@} of function @{<info>%s@} is \
95-
never used"
96-
s
97-
(decl.path |> Path.withoutHead)));
87+
| {declKind = Value {optionalArgs}}
88+
when active ()
89+
&& not (ProcessDeadAnnotations.isAnnotatedGenTypeOrLive decl.pos) ->
90+
optionalArgs
91+
|> OptionalArgs.iterUnused (fun s ->
92+
Log_.info ~loc:(decl |> declGetLoc) ~name:"Warning Unused Argument"
93+
(fun ppf () ->
94+
Format.fprintf ppf
95+
"optional argument @{<info>%s@} of function @{<info>%s@} is \
96+
never used"
97+
s
98+
(decl.path |> Path.withoutHead)));
9899
optionalArgs
99100
|> OptionalArgs.iterAlwaysUsed (fun s nCalls ->
100101
Log_.info ~loc:(decl |> declGetLoc)

0 commit comments

Comments
 (0)