diff options
author | Jeremy Evans <[email protected]> | 2021-07-09 21:44:01 -0700 |
---|---|---|
committer | git <[email protected]> | 2021-07-10 13:44:17 +0900 |
commit | 289fd3c801495b8188b8549b5a095cd479d048de (patch) | |
tree | 08c016581c514a9f7957988d22213945fcf2115f /lib/cgi.rb | |
parent | 6072239121360293dbd2ed607f16b6a11668999a (diff) |
[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
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.
Fixes [Bug #17530]
https://github.com/ruby/irb/commit/4ed2187f76
Diffstat (limited to 'lib/cgi.rb')
0 files changed, 0 insertions, 0 deletions