Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect "Unused local variable" inspection #139

Open
szhorvat opened this issue Oct 23, 2019 · 1 comment
Open

Incorrect "Unused local variable" inspection #139

szhorvat opened this issue Oct 23, 2019 · 1 comment
Assignees
Labels

Comments

@szhorvat
Copy link
Contributor

szhorvat commented Oct 23, 2019

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:

image


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.

@halirutan halirutan added the bug label Oct 23, 2019
@halirutan halirutan added this to High priority in Version 2020.1 Goals Dec 30, 2019
@halirutan
Copy link
Owner

Yep, when shit hits the fan... This will take another session to fix, but I identified the problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Version 2020.1 Goals
  
High priority
Development

No branches or pull requests

2 participants