Skip to content

Accidental if instead of a block #206

@schneems

Description

@schneems

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions