Project

General

Profile

Actions

Bug #12295

closed

Ripper not emitting on_parse_error for global variable name syntax errors

Added by lsegal (Loren Segal) almost 8 years ago. Updated over 7 years ago.

Status:
Rejected
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux-gnu]
[ruby-core:74988]

Description

Ripper is not emitting the on_parse_error event for certain types of syntax errors, specifically for the following snippet of code:

:~$

Here is the Ruby syntax error:

$ ruby -v
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-linux-gnu]
$ ruby -e ':~$'
-e:1: `$' without identifiers is not allowed as a global variable name

Here is the expected Ripper result for a syntax error emitting on_parse_error:

$ ruby -rripper -e 'class X < Ripper; def on_parse_error(m) puts "ERROR #{m}" end end; X.parse "class;end"'
ERROR syntax error, unexpected ';'

Here is reproduction for the omitted on_parse_error event:

$ ruby -rripper -e 'class X < Ripper; def on_parse_error(m) puts "ERROR #{m}" end end; X.parse ":~$"'
$

Note the lack of ERROR message. The expectation is that this parse error will emit the on_parse_error event in Ripper.

I reproduced this in Ruby 2.3.0, I have not tested 2.2 or dev, so I don't know if it needs porting, though I imagine it does.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0