modular / modular/modular

[BUG][LSP] The LSP incorrectly reports the loop variable as unused in functions that raise exceptions

Open
#4,182 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug modular-repo mojo
Dominant language
Mojo
Stars
29.8k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

Bug description

As title.

Steps to reproduce
fn main() raises:
  for i in range(10):
    print(i)  # unused variable 'i'
System information

mojo 25.3.0.dev2025032205 (087f9fe8)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the diagnostic with the Mojo LSP using the function and loop shown in the issue. Trace the LSP's unused-variable analysis for loop variables in functions declared with raises. Done means the example no longer reports i as unused, with coverage for this case if the repository provides a relevant test location.

Written by the indexing model from the issue text.

Assessment

Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.