roc
roc copied to clipboard
Unused def is not reported as unused
This (correctly) warns about the Action type alias being unused, but then (incorrectly) does not report that button is unused.
app "hello-rust"
packages { pf: "platform" }
imports []
provides [ main ] to pf
Elem state :
[
Button (ButtonConfig state) (Elem state),
Text Str,
Col (List (Elem state)),
Row (List (Elem state)),
]
ButtonConfig state : { onPress : state, PressEvent -> Action state }
PressEvent : { button : [ Touch, Mouse [ Left, Right, Middle ] ] }
Action state : [ ]
greeting =
hi = "Hello"
name = "World"
"\(hi), \(name)!\n"
main =
button = Button { onPress : \_, _ -> None } (Text "Hello, button!")
greeting
Looks to do the correct reporting on trunk!
» Elem state :
… [
… Button (ButtonConfig state) (Elem state),
… Text Str,
… Col (List (Elem state)),
… Row (List (Elem state)),
… ]
…
… ButtonConfig state : { onPress : state, PressEvent -> Action state }
…
… PressEvent : { button : [ Touch, Mouse [ Left, Right, Middle ] ] }
…
… Action state : [ ]
…
… greeting =
… hi = "Hello"
… name = "World"
…
… "\(hi), \(name)!\n"
…
… main =
… button = Button { onPress : \_, _ -> None } (Text "Hello, button!")
…
… greeting
… main
── UNUSED TYPE ALIAS PARAMETER ─────────────────────────────────────────────────
The state type parameter is not used in the Action alias definition:
16│ Action state : [ ]
^^^^^
Roc does not allow unused type parameters!
Tip: If you want an unused type parameter (a so-called "phantom
type"), read the guide section on phantom values.
── UNUSED DEFINITION ───────────────────────────────────────────────────────────
button is not used anywhere in your code.
25│ button = Button { onPress : \_, _ -> None } (Text "Hello, button!")
^^^^^^
If you didn't intend on using button then remove it so future readers
of your code don't wonder why it is there.
Closing as resolved on main.