Project

General

Profile

Actions

Bug #18988

closed

Ripper cannot parse some code that has regexp named capture

Added by tompng (tomoya ishida) about 2 years ago. Updated 9 months ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.0dev (2022-08-29T15:47:09Z :detached: cd7506593a) [x86_64-linux]
[ruby-core:109798]

Description

Ripper does not seems to recognize regexp named capture defining new local variables, fails to parse some code.

requie 'ripper'

# expect syntax ok, got syntax error
Ripper.sexp("/(?<a>)/ =~ ''; x = a **a, a if false")

# expect syntax error, got syntax ok
Ripper.sexp("/(?<a>)/ =~ ''; x = a **a, **a if false")

# "exit" is a method call, got string_literal
Ripper.sexp("/(?<a>)/ =~ ''; a %(exit)")
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0