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.

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.

2 participants