Skip to content
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

Accidental if instead of a block #206

Open
schneems opened this issue Sep 28, 2023 · 0 comments
Open

Accidental if instead of a block #206

schneems opened this issue Sep 28, 2023 · 0 comments

Comments

@schneems
Copy link
Collaborator

schneems commented Sep 28, 2023

I don't know if we can improve this but I hit this syntax error today when writing rspec:

Unmatched keyword, missing `end' ?
  2  describe "something" do
> 3    if "does something" do
> 5    end
  6  end
/tmp/scratchrb:3: syntax error, unexpected `do', expecting `then' or ';' or '\n' (SyntaxError)
  if "does something" do
                      ^~

(I used if instead of it).

Both if and do need an end. I think we could explain this better. In this case the original error says "unexpected do', expecting then' or ';' or '\n'". Perhaps as we're trying to explain the problem we should verify that the syntax error of our captured block matches the syntax error of the document, do something differently.

Generated by this code:

describe "something" do
  if "does something" do
    print "foo"
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant