Open
Description
The "Unused local variable" inspection sometimes triggers incorrectly for a Module
variable that is used as a value (i.e. right-hand-side of =
) in the variable list of a second enclosed Module
.
Code to reproduce it (probably not quite minimal, but almost):
fun[opt : OptionsPattern[]] :=
Module[{options = Association@Flatten[{opt}]},
Module[{foo = options["boo"]},
foo
]
]
Screenshot:
Update with shorter examples.
The following trigger the inspection incorrectly:
Module[{b},
Module[{a = b},
a; b
]
]
Block[{b},
Block[{a = b},
a
]
]
The following do not trigger the inspection:
Function[b,
Module[{a = b},
a
]
]
Block[{b},
Module[{a = b},
a
]
]
The inner and the outer localizing construct must be the same for the inspection to trigger.
Activity