Skip to content

Include [ and [[ in call argument diagnostic disabling #803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DavisVaughan
Copy link
Contributor

@DavisVaughan DavisVaughan commented May 14, 2025

Addresses posit-dev/positron#5271
Addresses part of posit-dev/positron#3749 (not the pipe part)

# We currently disable diagnostics anytime we are here:
fn(arg1, arg2)
  |----------|

# But not here
data[arg1, arg2]
    |----------|

# And not here
data[[arg1, arg2]]
    |------------|

This causes issues for data.table, who uses NSE inside [. We often treat function calls, subset, and subset2 pretty similarly (in the formatter they are treated almost identically). For now it seems like the right thing to do to make data.table usable in Positron is to also disable diagnostics inside subset (and subset2 for consistency).

I've done this by unifying some code paths that differed between the two and generalizing some field names.

Screenshot 2025-05-14 at 10 25 08 AM Screenshot 2025-05-14 at 10 26 22 AM

@DavisVaughan DavisVaughan requested review from lionel- and Copilot May 14, 2025 14:49
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request unifies the handling of function calls and subset/subset2 nodes in the diagnostic logic to disable diagnostics for call-like arguments, addressing issues with data.table usage. Key changes include renaming the context flag from in_call to in_call_like_arguments, consolidating recursion functions for call-like nodes, and updating corresponding tests.

Comments suppressed due to low confidence (1)

crates/ark/src/lsp/diagnostics.rs:1340

  • [nitpick] Ensure that the new test name accurately reflects that it now covers both function call diagnostics and subset/subset2 cases, making the purpose of the test clearer.
fn test_assignment_within_call_like() {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant