[BUG][LSP] The LSP incorrectly reports the loop variable as unused in functions that raise exceptions
Open
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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