Skip to content

Bad Label: Missing [ identified as an "unmatched end #87

@schneems

Description

@schneems

After #83 this code:

def foo
  1,2,3,4]
end

Produces this incorrect label:

DeadEnd: Unmatched `end` detected

This code has an unmatched `end`. Ensure that all `end` lines
in your code have a matching syntax keyword  (`def`,  `do`, etc.)
and that you don't have any extra `end` lines.

file: /tmp/scratch.rb
simplified:

      1  def foo
    ❯ 2    1,2,3,4]
      3  end

Known syntax error variations:

Here are some syntax errors that Ruby will generate for various code:

$ cat <<EOF | ruby -wc
def foo
  1,2,3,4]
end
EOF
-:2: syntax error, unexpected ',', expecting `end'
  1,2,3,4]
$ cat <<EOF | ruby -wc
def foo
  foo = 1,2,3,4]
end
EOF
-:2: syntax error, unexpected ']', expecting `end'
  foo = 1,2,3,4]

Fix

This is related to #68 because missing a leading bracket seems to be a general special case. Ideally, we tell the user that they're missing the bracket. If we can't do that, maybe we can avoid outputting an incorrect message.

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