Skip to content

Backwards label on brackets #85

@schneems

Description

@schneems

This label seems backward:

DeadEnd: Unmatched `]` detected

file: /tmp/scratch.rb
simplified:

      1  def foo
    ❯ 2    foo = [ 1,1,1
      3  end

The problem isn't an unmatched "]", the problem is an unmatched "[", to fix it a "]" is needed.

$ ruby -wc /tmp/scratch.rb
/tmp/scratch.rb:3: syntax error, unexpected `end', expecting ']'

I think we should change the label/banner to be

Unmatched `[` it appears `]` is missing

The cases I know off the top of my head for these single character chases are:

  • Square brackets []
  • Curly brackets {}
  • Parens ()
  • Pipe chars || (but these are not directional)

My thought would be to make a hash map from one char to it's logical inverse and use that for the display. Also, all of this banner/label logic is bundled together in DisplayInvalidBlocks. It might be worth making the banner/label stuff it's own class and have it be consumed by DisplayInvalidBlocks instead.

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