Project

General

Profile

Actions

Bug #22597

open

Regexp named capture names with invalid source encoding

Bug #22597: Regexp named capture names with invalid source encoding

Added by kddnewton (Kevin Newton) about 6 hours ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:127565]

Description

Parse.y uses the resolved encoding of a regexp when introducing named captures. Prism uses the source encoding. This almost always works, but:

# encoding: us-ascii
/(?<\u3042>x)/ =~ "x"

This results in a "あ" UTF-8 local that is invisible to user code unless accessed through binding.local_variable_get. This is such a niche unrealistic use case I didn't even really want to report it. But for the sake of simplicity, could we say it's alright to not introduce local variables through regexp named captures that cannot be represented in the source encoding?

No data to display

Actions

Also available in: PDF Atom