Backport #2233
[PATCH] Ripper parsing Proc call as: f.() or f::() crashes
| Status: | Closed | Start date: | 10/20/2009 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 100% |
||
| Category: | - | |||
| Target version: | - |
Description
Ripper seems to crash (with YARV and C stack trace) when trying to parse the two Proc call conveniences added to Ruby 1.9.x where the 'call' keyword is eliminated.
>> Ripper.sexp("f.()")
<system crash>
>> Ripper.sexp("f::()")
<system crash>
The problem seems to be that Ripper is inserting 'call' in the parse stream but was using rb_intern instead of ripper_intern. The included patch calls the ripper_intern and fixes the crash.
With the patch:
>> Ripper.sexp("f.()")
=> [:program, [[:method_add_arg, [:call, [:paren, [:var_ref, [:ident, "f", [1, 0]]]], :".", :call], [:arg_paren, nil]]]]
>> Ripper.sexp("f::()")
=> [:program, [[:method_add_arg, [:call, [:paren, [:var_ref, [:ident, "f", [1, 0]]]], :"::", :call], [:arg_paren, nil]]]]
Associated revisions
* parse.y (method_call): dispatch symbols. a patch from Andy Keep in
[ruby-core:26169]. [ruby-core:26165]
merges r25402,r25404,r25405,r25406 and r25407 from trunk into ruby_1_9_1.
--
* parse.y (parser_here_document): dispatch delayed heredoc
contents. based on a patch from Andy Keep in [ruby-core:24855].
--
* parse.y (mlhs_basic): fixed handling splat in middle of mlhs. a
patch from Andy Keep in [ruby-core:26163]
--
* parse.y (method_call): dispatch symbols. a patch from Andy Keep in
[ruby-core:26169]. [ruby-core:26165]
--
* test/ripper/test_*.rb: fixed indent.
--
* parse.y (ripper_intern): enable literal optimization.
History
Updated by Andy Keep over 2 years ago
- File parse.y.callless_call_patch added
A small addenda, it seems like the current version of the ripper code was (needlessly?) adding an extra set of parenthesis to the parser results. So f.() was parsed as (f).call() and f::() was parsed as (f).call(). I've re-patched it to remove the extra (). (The original patch fixed f::() being parsed as f.call() instead of f::call()).
Updated by Nobuyoshi Nakada over 2 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r25405. Andy, thank you for your reporting of the issue. You have greatfully contributed toward Ruby. May Ruby be with you.
Updated by Nobuyoshi Nakada about 2 years ago
- Status changed from Closed to Assigned
- Assignee set to Yuki Sonoda
Updated by Yuki Sonoda about 2 years ago
- Status changed from Assigned to Closed
This issue was solved with changeset r26013. Andy, thank you for reporting this issue. Your contribution to Ruby is greatly appreciated. May Ruby be with you.