-
Notifications
You must be signed in to change notification settings - Fork 482
Open
Description
Issue
I recently updated a project to use Rescript 12.2.0, and observed some differences in the issues reported by reanalyze coming from Rescript 11.1.4.
Issue described below is reproducible in repo: https://github.com/konradtho/rescript-analyze-issues.
Short version
In the Rescript 12 project I have defined a function with an optional argument used by a React provider.
let doSomethingContext = React.createContext((_arg: string, ~optArg as _: option<string>=?) => ())
module DoSomethingProvider = {
module Provider = {
let make = React.Context.provider(doSomethingContext)
}
@react.component
let make = (~children) => {
let doSomething = (arg: string, ~optArg: option<string>=?) => {
switch optArg {
| Some(optArg) => Console.log2(arg, optArg)
| None => Console.log(arg)
}
}
<Provider value=doSomething>
{children}
</Provider>
}
}When used by two components: One using the optional argument and one not using the optional argument, you get this output when running yarn rescript-tools reanalyze -dce:
Warning Redundant Optional Argument
/.../src/App.res:42:5-69
optional argument action of function ComponentUsingAction.dispatchNotification is always supplied (1 calls)
Warning Unused Argument
/.../src/App.res:57:5-69
optional argument action of function ComponentNotUsingAction.dispatchNotification is never used
Warning Unused Argument
/.../src/App.res:13:5-289
optional argument action of function NotificationProvider.dispatchNotification is never used
Warning Unused Argument
/../src/App.res:23:3-75
optional argument action of function NotificationProvider.useNotification is never used
Analysis reported 4 issues (Warning Redundant Optional Argument:1, Warning Unused Argument:3)
where as running the same command and the same code in a Rescript 11 project gives the output:
Analysis reported 0 issues
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels