File tree Expand file tree Collapse file tree 3 files changed +47
-23
lines changed
Expand file tree Collapse file tree 3 files changed +47
-23
lines changed Original file line number Diff line number Diff line change 11## HEAD (unreleased)
22
3+ - Consider if syntax error caused an unexpected variable instead of end (https://github.com/zombocom/dead_end/pull/58 )
4+
5+ ## 1.1.5
6+
37- Parse error once and not twice if there's more than one available (https://github.com/zombocom/dead_end/pull/57 )
48
59## 1.1.4
Original file line number Diff line number Diff line change @@ -51,14 +51,14 @@ def on_parse_error(msg)
5151 when /unexpected end-of-input/
5252 @error_symbol = :missing_end
5353 when /expecting end-of-input/
54- @error_symbol = :unmatched_syntax
5554 @unmatched_symbol = :end
56- when /unexpected `end'/ , # Ruby 2.7 and 3.0
57- /unexpected end/ , # Ruby 2.6
58- /unexpected keyword_end/i # Ruby 2.5
59-
60- match = @error . match ( /expecting '(?<unmatched_symbol>.*)'/ )
61- @unmatched_symbol = match [ :unmatched_symbol ] . to_sym if match
55+ @error_symbol = :unmatched_syntax
56+ when /unexpected .* expecting '(?<unmatched_symbol>.*)'/
57+ @unmatched_symbol = $1. to_sym if $1
58+ @error_symbol = :unmatched_syntax
59+ when /unexpected `end'/ , # Ruby 2.7 and 3.0
60+ /unexpected end/ , # Ruby 2.6
61+ /unexpected keyword_end/i # Ruby 2.5
6262
6363 @error_symbol = :unmatched_syntax
6464 else
Original file line number Diff line number Diff line change @@ -18,25 +18,45 @@ module DeadEnd
1818 ) . to eq ( :end )
1919 end
2020
21- it "determines the type of syntax error to be an unmatched pipe" do
22- source = <<~EOM
23- class Blerg
24- Foo.call do |a
25- end # one
21+ context "determines the type of syntax error to be an unmatched pipe" do
22+ it "with unexpected 'end'" do
23+ source = <<~EOM
24+ class Blerg
25+ Foo.call do |a
26+ end # one
2627
27- puts lol
28- class Foo
29- end # two
30- end # three
31- EOM
28+ puts lol
29+ class Foo
30+ end # two
31+ end # three
32+ EOM
3233
33- expect (
34- DeadEnd . invalid_type ( source ) . error_symbol
35- ) . to eq ( :unmatched_syntax )
34+ expect (
35+ DeadEnd . invalid_type ( source ) . error_symbol
36+ ) . to eq ( :unmatched_syntax )
3637
37- expect (
38- DeadEnd . invalid_type ( source ) . unmatched_symbol
39- ) . to eq ( :| )
38+ expect (
39+ DeadEnd . invalid_type ( source ) . unmatched_symbol
40+ ) . to eq ( :| )
41+ end
42+
43+ it "with unexpected local variable or method" do
44+ source = <<~EOM
45+ class Blerg
46+ [].each do |a
47+ puts a
48+ end
49+ end
50+ EOM
51+
52+ expect (
53+ DeadEnd . invalid_type ( source ) . error_symbol
54+ ) . to eq ( :unmatched_syntax )
55+
56+ expect (
57+ DeadEnd . invalid_type ( source ) . unmatched_symbol
58+ ) . to eq ( :| )
59+ end
4060 end
4161
4262 it "determines the type of syntax error to be an unmatched bracket" do
You can’t perform that action at this time.
0 commit comments