REditorSupport / REditorSupport/languageserver
Incorrect `variable assigned but may not be used` warning
Open
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 675
- Forks
- 118
- Avg merge
- 1d 37m
- Merged PRs (30d)
- 11
Description
With the following minimal-ish code snippet, I'm getting a warning that model was assigned but may not be used:
boot_wls <- function(data, indices) {
data <- data[indices, ]
model <- lm(y ~ x1 + x2 + x3, data)
w <- 1 / fitted(lm(abs(residuals(model)) ~ x1 + x2 + x3, data))^2
w
}
Contributor guide
No contributing guide indexed for this repository
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 warning with the R function shown in the issue and trace the language server's unused-variable analysis for the model assignment. Determine why its use through residuals(model) is missed; done means this example no longer reports model as possibly unused, with regression coverage for the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100