File tree 2 files changed +16
-2
lines changed
2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -2837,14 +2837,21 @@ def on_regexp_end(value)
2837
2837
# :call-seq:
2838
2838
# on_regexp_literal: (
2839
2839
# RegexpContent regexp_content,
2840
- # RegexpEnd ending
2840
+ # (nil | RegexpEnd) ending
2841
2841
# ) -> RegexpLiteral
2842
2842
def on_regexp_literal ( regexp_content , ending )
2843
+ location = regexp_content . location
2844
+
2845
+ if ending . nil?
2846
+ message = "Cannot find expected regular expression ending"
2847
+ raise ParseError . new ( message , *find_token_error ( location ) )
2848
+ end
2849
+
2843
2850
RegexpLiteral . new (
2844
2851
beginning : regexp_content . beginning ,
2845
2852
ending : ending . value ,
2846
2853
parts : regexp_content . parts ,
2847
- location : regexp_content . location . to ( ending . location )
2854
+ location : location . to ( ending . location )
2848
2855
)
2849
2856
end
2850
2857
Original file line number Diff line number Diff line change @@ -41,6 +41,13 @@ def test_errors_on_missing_end_with_location
41
41
assert_equal ( 4 , error . column )
42
42
end
43
43
44
+ def test_errors_on_missing_regexp_ending
45
+ error =
46
+ assert_raises ( Parser ::ParseError ) { SyntaxTree . parse ( "a =~ /foo" ) }
47
+
48
+ assert_equal ( 5 , error . column )
49
+ end
50
+
44
51
def test_errors_on_missing_token_without_location
45
52
assert_raises ( Parser ::ParseError ) { SyntaxTree . parse ( ":\" foo" ) }
46
53
end
You can’t perform that action at this time.
0 commit comments