posit-dev / posit-dev/positron

Ark: Consider if we can automatically enhance `parseError`s

Open
#1,867 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: kernels lang: r
Dominant language
TypeScript
Stars
4.3k
Forks
184
Avg merge
1d 9h
Merged PRs (30d)
195

Description

parse() has been enhanced to give classed parseErrors in some cases, and these typically include a file name and line / col number.
https://github.com/wch/r-source/commit/48b9036b120d7ac82c9aa61e6d47225de88d6eb2

> str(rlang::catch_cnd(parse(text = "x |> _")))
List of 6
 $ message : chr "The pipe operator requires a function call as RHS (<text>:1:6)"
 $ call    : chr "_"
 $ value   : NULL
 $ filename: chr "<text>"
 $ lineno  : int 1
 $ colno   : int 6
 - attr(*, "class")= chr [1:4] "RHSnotFnCall" "parseError" "error" "condition"

When this comes from an actual file, like:

Caused by error in `parse()`:
! /Users/hadleywickham/Documents/devtools/roxygen/R/namespace.R:99:38: unexpected string constant

It would be cool if we could catch and enhance this error message with a clickable link

Note that not all parse errors get this subclass, only some of them (in particular the "unexpected string constant" doesn't seem to) but maybe that will expand over time.

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 with the R parseError examples and the linked R source commit, then trace how Positron receives and displays these errors. Done means defining and implementing the proposed clickable link for file, line, and column information, while accounting for parse errors that lack the subclass.

Written by the indexing model from the issue text.

Assessment

Tech stack
r
Domain
devtools
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.