-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange behavior for inline blocks #41
Comments
I got the the same problem using String interpolation inside a block. So I guess there should be made some changes on how interpolation braces are identified.
Commas in |
@ismaelga Were you also using Ruby 2.0? My suspicion is that these errors are all related to differences in the output from Ripper in 1.9 and 2.0. They are bugs nonetheless, but it would be interesting to see if they appear in Ruby 1.9 or not. |
@jonas054 Yeah. I just tested on 1.9.3 and it worked there. So this seems to be only on 2.0.0 |
And the output from Ripper is the same on both. So it should be something else |
Minimal ruby source: foo { "#{n}" } I pry'ed blocks.rb, and this is what I get for {70102431113960=>[0], 70102431112780=>[2, 10], 70102431121220=>[6]} Here's the matching {0=>[:program, :method_add_block, :method_add_arg, :fcall, :@ident],
2=>[:program, :method_add_block, :brace_block],
10=>[:program, :method_add_block, :brace_block],
6=>
[:program,
:method_add_block,
:brace_block,
:string_literal,
:string_content,
:string_embexpr,
:vcall,
:@ident]} while this is what I get for {70225979303160=>[0], 70225979322180=>[2], 70225979338680=>[6]} and the matching {0=>[:program, :method_add_block, :method_add_arg, :fcall, :@ident],
2=>[:program, :method_add_block, :brace_block],
6=>
[:program,
:method_add_block,
:brace_block,
:string_literal,
:string_content,
:string_embexpr,
:vcall,
:@ident]} So Next stop, |
In [[:on_ident, "foo"],
[:on_sp, " "],
[:on_lbrace, "{"],
[:on_sp, " "],
[:on_tstring_beg, "\""],
[:on_embexpr_beg, "\#{"],
[:on_ident, "n"],
[:on_embexpr_end, "}"],
[:on_tstring_end, "\""],
[:on_sp, " "],
[:on_embexpr_end, "}"]] Since it misses in |
I focused too much on the last brace and finally found the cause: On ruby 2.0, this is what [[:on_ident, "foo"],
[:on_sp, " "],
[:on_lbrace, "{"],
[:on_sp, " "],
[:on_tstring_beg, "\""],
[:on_embexpr_beg, "\#{"],
[:on_ident, "n"],
[:on_embexpr_end, "}"],
[:on_tstring_end, "\""],
[:on_sp, " "],
[:on_rbrace, "}"]] Notice how It follows that:
|
Fixed in PR #46. |
That's some impressive bug hunting you did, @lloeki! You fixed this issue just as I was about to take a closer look at it. Thanks! |
@lloeki awesome! 👍 |
Good job! |
RuboCop 0.4.1 is now out and features that fix! |
Just an example:
Code:
Exception:
Seems like an bug for me.
By the way, if I add braces around the block (making this code invalid)
i get:
Is this a correct behavior for invalid syntax?
Next one -
reduce
.I get:
Ehm? What comma? I've already had that comma here.
Hope that helps!
The text was updated successfully, but these errors were encountered: