File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 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)
28372837 # :call-seq:
28382838 # on_regexp_literal: (
28392839 # RegexpContent regexp_content,
2840- # RegexpEnd ending
2840+ # (nil | RegexpEnd) ending
28412841 # ) -> RegexpLiteral
28422842 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+
28432850 RegexpLiteral . new (
28442851 beginning : regexp_content . beginning ,
28452852 ending : ending . value ,
28462853 parts : regexp_content . parts ,
2847- location : regexp_content . location . to ( ending . location )
2854+ location : location . to ( ending . location )
28482855 )
28492856 end
28502857
Original file line number Diff line number Diff line change @@ -41,6 +41,13 @@ def test_errors_on_missing_end_with_location
4141 assert_equal ( 4 , error . column )
4242 end
4343
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+
4451 def test_errors_on_missing_token_without_location
4552 assert_raises ( Parser ::ParseError ) { SyntaxTree . parse ( ":\" foo" ) }
4653 end
You can’t perform that action at this time.
0 commit comments