Bug #4561
closed1.9.2 requires parentheses around argument of method call in an array, where 1.8.7 did not
Description
[dave hladik:~] cat method_call_without_parens_in_array.rb
def method_name(arg)
end
[ method_name 'value' ]
[dave hladik:~] ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10]
[dave hladik:~] ruby method_call_without_parens_in_array.rb
[dave hladik:~] rvm 1.9.2
[dave hladik:~] ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
[dave hladik:~] ruby method_call_without_parens_in_array.rb
method_call_without_parens_in_array.rb:4: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
[ method_name 'value' ]
^
method_call_without_parens_in_array.rb:4: syntax error, unexpected ']', expecting $end
[dave hladik:~] rvm system
[dave hladik:~] ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10]
[dave hladik:~] cat method_call_with_parens_in_array.rb
def method_name(arg)
end
[ method_name('value') ]
[dave hladik:~] ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10]
[dave hladik:~] ruby method_call_with_parens_in_array.rb
[dave hladik:~] rvm 1.9.2
[dave hladik:~] ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
[dave hladik:~] ruby method_call_with_parens_in_array.rb
no error¶
Files
Updated by dschweisguth (Dave Schweisguth) over 13 years ago
=begin
Same thing with pre formatting:
[dave hladik:~] cat method_call_without_parens_in_array.rb
def method_name(arg)
end
[ method_name 'value' ]
[dave hladik:~] rvm system
[dave hladik:~] ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10]
[dave hladik:~] ruby method_call_without_parens_in_array.rb
[dave hladik:~] rvm 1.9.2
[dave hladik:~] ruby -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
[dave hladik:~] ruby method_call_without_parens_in_array.rb
method_call_without_parens_in_array.rb:4: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
[ method_name 'value' ]
^
method_call_without_parens_in_array.rb:4: syntax error, unexpected ']', expecting $end
[dave hladik:~] cat method_call_with_parens_in_array.rb
def method_name(arg)
end
[ method_name('value') ]
[dave hladik:~] rvm system
[dave hladik:~] ruby -v
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10]
[dave hladik:~] ruby method_call_with_parens_in_array.rb
[dave hladik:~] rvm 1.9.2
[dave hladik:~] ruby method_call_with_parens_in_array.rb
no error¶
=end
Updated by naruse (Yui NARUSE) over 13 years ago
- Status changed from Open to Assigned
- Assignee set to matz (Yukihiro Matsumoto)
=begin
=end
Updated by Eregon (Benoit Daloze) over 13 years ago
=begin
That has bitten me a few times too, but I accepted it as it is probably clearer in a long expression.
I'm curious to see why this changed.
=end
Updated by ko1 (Koichi Sasada) over 13 years ago
Matz, could you reply?
Updated by matz (Yukihiro Matsumoto) over 13 years ago
- ruby -v changed from ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0] to -
Hi,
In message "Re: [ruby-core:36994] [Ruby 1.9 - Bug #4561] 1.9.2 requires parentheses around argument of method call in an array, where 1.8.7 did not"
on Sat, 11 Jun 2011 15:58:33 +0900, Koichi Sasada redmine@ruby-lang.org writes:
|Bug #4561: 1.9.2 requires parentheses around argument of method call in an array, where 1.8.7 did not
|http://redmine.ruby-lang.org/issues/4561
|
|Matz, could you reply?
It's an intentional syntax change in 1.9.
matz.
Updated by Anonymous over 13 years ago
Yukihiro Matsumoto wrote:
It's an intentional syntax change in 1.9.
I have run into the same issue today and wasn't sure if it was a bug or intentional. Nice to find both this issue and your recent response.
Out of curiosity, what is the reasoning behind this change? It seems a bit unintuitive that foo(bar 5) and {bar 5} work, even [bar { baz }], but [bar 5] not. All four are enclosed calls without parenthesis. Is there an ambiguity nearby that this syntax change is trying to clarify?
Updated by nahi (Hiroshi Nakamura) over 13 years ago
- Assignee changed from matz (Yukihiro Matsumoto) to ko1 (Koichi Sasada)
- Target version set to 1.9.3
Updated by ko1 (Koichi Sasada) over 13 years ago
- Status changed from Assigned to Closed