From: "kddnewton (Kevin Newton) via ruby-core" Date: 2026-11-17T21:51:51+00:00 Subject: [ruby-core:127565] [Ruby Bug#22597] Regexp named capture names with invalid source encoding Issue #22597 has been reported by kddnewton (Kevin Newton). ---------------------------------------- Bug #22597: Regexp named capture names with invalid source encoding https://bugs.ruby-lang.org/issues/22597 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- 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? -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/