Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## HEAD (unreleased)

- Expand explanations coming from additional Ripper errors (https://github.com/zombocom/dead_end/pull/117)
- Fix explanation involving shorthand syntax for literals like `%w[]` and `%Q{}` (https://github.com/zombocom/dead_end/pull/116)

## 3.0.2
Expand Down
6 changes: 6 additions & 0 deletions lib/dead_end/ripper_errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ def on_parse_error(msg)
@errors << msg
end

alias_method :on_alias_error, :on_parse_error
alias_method :on_assign_error, :on_parse_error
alias_method :on_class_name_error, :on_parse_error
alias_method :on_param_error, :on_parse_error
alias_method :compile_error, :on_parse_error

def call
@run_once ||= begin
@errors = []
Expand Down
13 changes: 13 additions & 0 deletions spec/unit/explain_syntax_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@

module DeadEnd
RSpec.describe "ExplainSyntax" do
it "handles shorthand syntaxes with non-bracket characters" do
source = <<~EOM
%Q* lol
EOM

explain = ExplainSyntax.new(
code_lines: CodeLine.from_source(source)
).call

expect(explain.missing).to eq([])
expect(explain.errors.join).to include("unterminated string")
end

it "handles %w[]" do
source = <<~EOM
node.is_a?(Op) && %w[| ||].include?(node.value) &&
Expand Down