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 <=?

Updated by nobu (Nobuyoshi Nakada) about 12 hours ago Actions #1

  • Backport changed from 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN to 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED

Updated by nobu (Nobuyoshi Nakada) about 12 hours ago Actions #2

  • Status changed from Open to Closed

Applied in changeset git|7db0202722a286011518bd291f51a15fb652dc02.


[Bug #22603] Fix off-by-one in named-capture local assignment

The longest name, __ENCODING__, has not been skipped.

Actions

Also available in: PDF Atom