[ruby/yarp] Handle interpolated regular expressions with the o flag for locals checking

https://github.com/ruby/yarp/commit/db95191207
This commit is contained in:
Kevin Newton 2023-08-18 09:16:10 -04:00 committed by Jemma Issroff
parent 524d99daaf
commit 0fd57ee01d
3 changed files with 29 additions and 2 deletions

View File

@ -481,6 +481,8 @@ module YARP
locals << []
when PostExecutionNode
locals.push([], [])
when InterpolatedRegularExpressionNode
locals << [] if node.once?
end
stack.concat(node.child_nodes.compact)

View File

@ -26,3 +26,5 @@ foo /bar/
/(?#\))/ =~ "hi"
%r#pound#
/aaa #{bbb}/o

View File

@ -1,6 +1,6 @@
ProgramNode(0...278)(
ProgramNode(0...293)(
[:foo],
StatementsNode(0...278)(
StatementsNode(0...293)(
[CallNode(0...9)(
nil,
nil,
@ -138,6 +138,29 @@ ProgramNode(0...278)(
(277...278),
"pound",
0
),
InterpolatedRegularExpressionNode(280...293)(
(280...281),
[StringNode(281...285)(nil, (281...285), nil, "aaa "),
EmbeddedStatementsNode(285...291)(
(285...287),
StatementsNode(287...290)(
[CallNode(287...290)(
nil,
nil,
(287...290),
nil,
nil,
nil,
nil,
2,
"bbb"
)]
),
(290...291)
)],
(291...293),
128
)]
)
)