Project

General

Profile

Actions

Bug #22603

closed

parse.y off-by-one (len < MAX_WORD_LENGTH) fails to skip __ENCODING__ in regexp named-capture local assignment

Bug #22603: parse.y off-by-one (len < MAX_WORD_LENGTH) fails to skip __ENCODING__ in regexp named-capture local assignment

Added by steviejj (Steven Johnstone) about 13 hours ago. Updated about 12 hours ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 4.1.0dev (2026-11-18T15:35:00Z HEAD 4414d3ea25) +PRISM [aarch64-linux]
[ruby-core:127588]

Description

$ ruby --parser=parse.y -e '/(?<__ENCODING__>a)/ =~ "a"; p [__ENCODING__, binding.local_variable_get(:__ENCODING__)]'
[#<Encoding:UTF-8>, "a"]
$ ruby -v
ruby 4.1.0dev (2026-11-18T15:35:00Z HEAD 4414d3ea25) +PRISM [aarch64-linux]

https://github.com/ruby/ruby/blob/353c293c1b1171916bd7c82f73751b01f2fb4cb4/parse.y#L15581 the comparison with MAX_WORD_LENGTH should be <=?

Actions

Also available in: PDF Atom