[ruby-core:127564] [Ruby Bug#22596] parse.y splits regexp literal on #@, meaning named captures change
Issue #22596 has been reported by kddnewton (Kevin Newton). ---------------------------------------- Bug #22596: parse.y splits regexp literal on #@, meaning named captures change https://bugs.ruby-lang.org/issues/22596 * Author: kddnewton (Kevin Newton) * Status: Open * Backport: 3.3: UNKNOWN, 3.4: UNKNOWN, 4.0: UNKNOWN ---------------------------------------- ```ruby /(?<captured>#@)/ =~ "#@" defined?(captured) ``` The `#@` changes this node to a dynamic regexp, which means named captures don't get added to the local table. But that's kind of a quirk of the lexer more than anything, since it's looking for an interpolated variable. Prism makes that a regexp node (as opposed to an interpolated regexp node) meaning the `captured` local gets defined. -- https://bugs.ruby-lang.org/
participants (1)
-
kddnewton (Kevin Newton)