Skip to content

Conversation

@DavisVaughan
Copy link
Contributor

@EmilHvitfeldt noted that you get no indication of syntax errors with if statements or loops without a body

image

This is a somewhat rare case in a "finished" R file, the loop or if statement has to:

  • Be the last statement in the file, or the last statement in a { block
  • Be missing a loop body or if statement consequence

But when you are interactively filling out a file from top to bottom for the first time, it can come up a lot, and the fact that there was no syntax error seemed like it was confusing some people.

You now get:

Screenshot 2025-12-16 at 11 53 22 AM

If you remove the if statement, you get:

Screenshot 2025-12-16 at 11 40 54 AM

With a for loop:

Screenshot 2025-12-16 at 11 46 20 AM

I've chosen to only squiggle the keyword (for, while, if, or repeat). Anything else felt too aggressive. Squiggling the whole loop node would extend arbitrarily far down the page because it keeps consuming new lines looking for a loop body that never exists.

Copy link
Contributor

@lionel- lionel- left a comment

Choose a reason for hiding this comment

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

LG!

It looks like function suffers from the same problem, probably worth fixing here too.

I also see a syntax error for ~ when there is a LHS, but no error when there is no LHS:
Image

edit: duh that's because ~1 is valid unary syntax

@DavisVaughan DavisVaughan merged commit 00ce2ef into main Jan 7, 2026
8 checks passed
@DavisVaughan DavisVaughan deleted the feature/show-missing-body branch January 7, 2026 15:11
@github-actions github-actions bot locked and limited conversation to collaborators Jan 7, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants