posit-dev / posit-dev/ark

False positive R diagnostic for a symbol that's defined within the relevant scope

Open
#989 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
337
Forks
32
Avg merge
8d 17h
Merged PRs (30d)
11

Description

Writing up something I first raised in Slack.

Even after devtools::load_all() inside testhtat's source, I see a No symbol named 'next_case' in scope. originating from here:
https://github.com/r-lib/testthat/blob/0b896ac12673ec27991c1b58292bd2463e829219/R/snapshot-manage.R#L121

But next_case() is defined in the same scope as update_cases(), together inside server(). The only way to eliminate this diagnostic is to move the definition of next_case() before the definition of update_cases(). @lionel- points out that this remedy might not always be possible, i.e. for 2 functions that call each other.

Analysis from my very pragmatic POV: the reason there should be no diagnostic is that both helpers are defined in the same non-global scope. So if update_cases() is being executed, that implies server() has been defined and is being executed, which implies next_case() is in scope.

System details:

Positron and OS details:

Positron Version: 2025.09.0 build 41
Code - OSS Version: 1.102.0
Commit: fd2186c301ecb6913b9614e22fe22c5423c6acdc
Date: 2025-08-11T03:42:41.022Z
Electron: 35.6.0
Chromium: 134.0.6998.205
Node.js: 22.15.1
V8: 13.4.114.21-electron.0
OS: Darwin arm64 24.6.0

.ps.ark.version()
#>                                                                                      branch 
#>                                                                                      "main" 
#>                                                                                      commit 
#>                                                                                   "8a51524" 
#>                                                                                        date 
#>                                                                   "2025-07-30 09:06:35 PDT" 
#>                                                                                      flavor 
#>                                                                                   "release" 
#>                                                                                        path 
#> "/Applications/Positron.app/Contents/Resources/app/extensions/positron-r/resources/ark/ark" 
#>                                                                                     version 
#>                                                                                   "0.1.201"
Session details:

Describe the issue:

Steps to reproduce the issue:

Open testthat as a folder in Positron. Source is at https://github.com/r-lib/testthat. The phenomenon of interest is definitely present as of SHA 0b896ac.

Run devtools::load_all(). Notice this remaining diagnostic in PROBLEMS:

Image

Expected or desired behavior:

This code should not generate a "no such symbol in scope" diagnostic.

Were there any error messages in the UI, Output panel, or Developer Tools console?

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

Reproduce the diagnostic by opening r-lib/testthat in Positron and running devtools::load_all(), then inspect the R diagnostic reported at snapshot-manage.R line 121. Determine how the analyzer handles mutually scoped functions such as update_cases() and next_case(); done means this valid same-scope reference no longer produces a “No symbol named” diagnostic.

Written by the indexing model from the issue text.

Assessment

Tech stack
r, rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.