[ruby/irb] Pass local variables from workspace binding to lexer
This fixes at least an issue where irb will incorrectly assume code opens a heredoc when it does not, such as this code:
s1='testing's2='this's2<<s1 p s1 s1
Ruby parses the s2 <<s1 as s2.<<(s1), not as a heredoc, because s2 is a local variable in scope. irb was using ripper without letting ripper know that s2 was a local variable, so ripper would lex it as a heredoc instead of a method call.
Fix the situation by prepending a line at line 0 with all local variable definitions in scope whenever lexing. This fixes the heredoc issue, and potentially other issues that depend on whether an identifier is a local variable or not.
[ruby/irb] Pass local variables from workspace binding to lexer
This fixes at least an issue where irb will incorrectly assume
code opens a heredoc when it does not, such as this code:
Ruby parses the
s2 <<s1ass2.<<(s1), not as a heredoc, becauses2is a local variable in scope. irb was using ripper withoutletting ripper know that
s2was a local variable, so ripper wouldlex it as a heredoc instead of a method call.
Fix the situation by prepending a line at line 0 with all local
variable definitions in scope whenever lexing. This fixes the
heredoc issue, and potentially other issues that depend on whether
an identifier is a local variable or not.
Fixes [Bug #17530]
https://github.com/ruby/irb/commit/4ed2187f76