Nimblesite / Nimblesite/Basilisk
False positive "returns `o` but `o` may be unbound on some paths"
Open
A pull request for this has already been merged.
- #298 by @abdushakoor12 — merged
awaiting-reply
critical
- Dominant language
- Rust
- Stars
- 54
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
error[names_unbound]: Function `occ` returns `o` but `o` may be unbound on some paths
--> taxonomy/shell.py:2169:12
|
2169 | return o
| ^
|
= help: Assign `o` unconditionally before the `return`, or add a default value
= note: Basilisk detects variables that are assigned only inside conditional branches (if/while/try) and may not be defined on every execution path
= see: https://www.basilisk-python.dev/errors/names_unbound
At https://github.com/JelleZijlstra/taxonomy/blob/9b359fac68b982f5dddd60d1b10e4089607dd571/taxonomy/shell.py#L2169 . But the function assigns to o in both the try and except blocks; it's always defined.
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 with taxonomy/shell.py at line 2169 and reproduce the names_unbound diagnostic for function occ. Trace Basilisk's handling of assignments across the try and except blocks, then verify that this case no longer reports an unbound variable while genuine conditional-path cases still do.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100