Actions
Bug #18988
closedRipper cannot parse some code that has regexp named capture
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.0dev (2022-08-29T15:47:09Z :detached: cd7506593a) [x86_64-linux]
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)")
Updated by tompng (tomoya ishida) over 2 years ago
- Subject changed from # Ripper cannot parse some code that has regexp named capture to Ripper cannot parse some code that has regexp named capture
Updated by jeremyevans0 (Jeremy Evans) over 1 year ago
It appears that YARP parses all of these correctly:
YARP.parse("/(?<a>)/ =~ ''; x = a **a, a if false").success?
=> true
YARP.parse("/(?<a>)/ =~ ''; x = a **a, **a if false").success?
=> false
YARP.parse("/(?<a>)/ =~ ''; a %(exit)")
# includes: ([CallNode(20...24)(nil, nil, (20...24), nil, nil, nil, nil, 2, "exit")])
Updated by yui-knk (Kaneko Yuichiro) 10 months ago
- Status changed from Open to Closed
This is solved by https://bugs.ruby-lang.org/issues/20257 (https://github.com/ruby/ruby/pull/9923).
Actions
Like0
Like0Like0Like0