Bug #4561
1.9.2 requires parentheses around argument of method call in an array, where 1.8.7 did not
| Status: | Closed | Start date: | 04/07/2011 | |
|---|---|---|---|---|
| Priority: | Normal | Due date: | ||
| Assignee: | % Done: | 0% |
||
| Category: | core | |||
| Target version: | 1.9.3 | |||
| ruby -v: | - |
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
History
Updated by Dave Schweisguth 11 months ago
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
Updated by Yui NARUSE 11 months ago
- Status changed from Open to Assigned
- Assignee set to Yukihiro Matsumoto
Updated by Benoit Daloze 11 months ago
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.
Updated by Koichi Sasada 9 months ago
Matz, could you reply?
Updated by Yukihiro Matsumoto 9 months 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 Julian Raschke 8 months 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 Hiroshi Nakamura 8 months ago
- Assignee changed from Yukihiro Matsumoto to Koichi Sasada
- Target version set to 1.9.3
Updated by Koichi Sasada 8 months ago
- Status changed from Assigned to Closed