[ruby-core:127588] [Ruby Bug#22603] parse.y off-by-one (len < MAX_WORD_LENGTH) fails to skip __ENCODING__ in regexp named-capture local assignment
Issue #22603 has been reported by steviejj (Steven Johnstone). ---------------------------------------- Bug #22603: parse.y off-by-one (len < MAX_WORD_LENGTH) fails to skip __ENCODING__ in regexp named-capture local assignment https://bugs.ruby-lang.org/issues/22603 * Author: steviejj (Steven Johnstone) * Status: Open * ruby -v: ruby 4.1.0dev (2026-11-18T15:35:00Z HEAD 4414d3ea25) +PRISM [aarch64-linux] * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ``` $ 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/p... the comparison with `MAX_WORD_LENGTH` should be `<=`? -- https://bugs.ruby-lang.org/
Issue #22603 has been updated by k0kubun (Takashi Kokubun). Backport changed from 3.3: REQUIRED, 3.4: REQUIRED, 4.0: REQUIRED to 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE ruby_4_0 commit:8120faddebfab6d63516c860ea378d32254573a7 merged revision(s) commit:7db0202722a286011518bd291f51a15fb652dc02. ---------------------------------------- Bug #22603: parse.y off-by-one (len < MAX_WORD_LENGTH) fails to skip __ENCODING__ in regexp named-capture local assignment https://bugs.ruby-lang.org/issues/22603#change-120156 * Author: steviejj (Steven Johnstone) * Status: Closed * ruby -v: ruby 4.1.0dev (2026-11-18T15:35:00Z HEAD 4414d3ea25) +PRISM [aarch64-linux] * Backport: 3.3: REQUIRED, 3.4: REQUIRED, 4.0: DONE ---------------------------------------- ``` $ 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/p... the comparison with `MAX_WORD_LENGTH` should be `<=`? -- https://bugs.ruby-lang.org/
participants (2)
-
k0kubun (Takashi Kokubun) -
steviejj (Steven Johnstone)